Jump to content

Idle curiousity


Nythrun

Recommended Posts

CamDawg mentioned a prospective addition to Tweaks V4 in another thread, and that's something I was working on myself.

 

So I'd love to know how you've been approaching weapon-proficienating NPCs :)

 

I wasn't content with the first draft of mine, so I started over with all of the actual effect adding shunted into external libraries - but in order to patch creatures in a minimally stupid way, the main .tp2 is demanding a plot of space fit for an imperium. Before finishing off the rest of the libraries, it might be nice to know if there's a briefer method which also isn't stupid. As I'd like a break from it for a few days, I figured I'd ask the experts.

 

Can post the tentative pre-alpha if you'd like, though it's about six thousand lines long in the current state and won't fit so easily :)

Link to comment

Right now, max stars (if available) go into the equipped weapon and then remaining stars are placed into other weapons (max if possible) until all stars are distributed. It's not accounting for dual-wielders and nothing is going into weapon styles. Kits that get non-standard maximums (i.e. swashbucklers) are also not being accounted for; nor am I checking if the weapon is illegal. This could be done easily enough with some 2da checks, but it's going to get very slow and horrible. Not perfect, but good enough.

 

Ideally, if the character is dual-wielding it should go equipped > offhand > 2 weapon style > other weapons; if not dual wielding then equipped > other > weapon styles (s&s, 2H, single weapon). Weapon style rates ahead of secondary weapons for dual-wielders because they're not going to change weapons in the middle of combat, whereas non-dual-wielders may be scripted to change from a bow to short sword to whatever. Weapon style profs are something I'd like to add in the next iteration.

 

I'm sure there are all sorts of redundancies in the code that can be removed, too.

 

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
 READ_LONG  0x1cc "biography" ELSE 0
 PATCH_IF (("%biography%" > 2147483646) OR ("%biography%" < 1)) BEGIN // non-joinables only
READ_BYTE 0x10 "dual1"
READ_BYTE 0x11 "dual2"
READ_BYTE 0x33 "fx_type" // short or long type of effect
READ_BYTE 0x234 "level1" // Highest attained level in primary class
READ_BYTE 0x235 "level2" // Highest attained level in secondary class
READ_BYTE 0x236 "level3" // Highest attained level in tertiary class
READ_BYTE 0x273 "class"  // corresponds to values in class.ids
READ_LONG 0x2b8 "itm_slot_off"
READ_LONG 0x2bc "itm_off"
READ_LONG 0x2c4 "fx_off"
SET "max" = 0
SET "total" = 0
SET "exists" = 0
SET "new_fx" = 0
SET "prof" = 255
SET "prof0" = 255
SET "prof1" = 255
SET "prof2" = 255
SET "prof3" = 255
// first let's figure out max number of stars in a weapon and total number of pips
PATCH_IF (("%class%" > 20) OR ("%class%" < 1)) BEGIN // classless monsters use mage progression
  SET "max" = 1
  SET "total" = 1 + ("%level1%" / 6)
END ELSE
// single classes are cake
PATCH_IF ("%class%" = 1) BEGIN // mage
  SET "max" = 1
  SET "total" = 1 + ("%level1%" / 6)
END ELSE
PATCH_IF ("%class%" = 2) BEGIN // fighter
  SET "max" = 5
  SET "total" = 4 + ("%level1%" / 3)
END ELSE
PATCH_IF ("%class%" = 3) BEGIN // cleric
  SET "max" = 1
  SET "total" = 2 + ("%level1%" / 4)
END ELSE
PATCH_IF ("%class%" = 4) BEGIN // thief
  SET "max" = 1
  SET "total" = 2 + ("%level1%" / 4)
END ELSE
PATCH_IF ("%class%" = 5) BEGIN // bard
  SET "max" = 1
  SET "total" = 2 + ("%level1%" / 4)
END ELSE
PATCH_IF ("%class%" = 6) BEGIN // paladin
  SET "max" = 2
  SET "total" = 4 + ("%level1%" / 3)
END ELSE
PATCH_IF ("%class%" = 11) BEGIN // druid
  SET "max" = 1
  SET "total" = 2 + ("%level1%" / 4)
END ELSE
PATCH_IF ("%class%" = 12) BEGIN // ranger
  SET "max" = 2
  SET "total" = 4 + ("%level1%" / 3)
END ELSE
PATCH_IF ("%class%" = 19) BEGIN // sorcerer
  SET "max" = 1
  SET "total" = 1 + ("%level1%" / 6)
END ELSE
PATCH_IF ("%class%" = 20) BEGIN // monk
  SET "max" = 2
  SET "total" = 2 + ("%level1%" / 4)
END ELSE BEGIN // multiclasses
  // multiclasses; first check for dual v multi
  PATCH_IF ((("%dual1%" BOR 0b11110111) = 0b11111111) OR	 // dual from fighter
			(("%dual1%" BOR 0b11101111) = 0b11111111) OR	 // dual from mage
			(("%dual1%" BOR 0b11011111) = 0b11111111) OR	 // dual from cleric
			(("%dual1%" BOR 0b10111111) = 0b11111111) OR	 // dual from thief
			(("%dual1%" BOR 0b01111111) = 0b11111111) OR	 // dual from druid
			(("%dual2%" BOR 0b11111110) = 0b11111111)) BEGIN // dual from fighter
	SET "dual" = 1
  END ELSE BEGIN
	SET "dual" = 0
	// below, multi-classes get their starting stars from all classes added--need to back those out
	PATCH_IF (("%class%" = 7) OR ("%class%" = 13) OR ("%class%" = 14)) BEGIN
	  SET "total" = ("%total%" - 1)
	END ELSE
	PATCH_IF (("%class%" = 10) OR ("%class%" = 17)) BEGIN
	  SET "total" = ("%total%" - 3)
	END ELSE BEGIN
	  SET "total" = ("%total%" - 2)
	END
  END
  PATCH_IF ("%class%" = 13) BEGIN // mage-x multis
	SET "max" = 1
	SET "total" = "%total%" + 1 + ("%level1%" / 6)
  END
  PATCH_IF (("%class%" = 7) OR ("%class%" = 10) OR ("%class%" = 14) OR ("%class%" = 17)) BEGIN // x-mage(-x) multis
	SET "max" = 1
	SET "total" = "%total%" + 1 + ("%level2%" / 6)
  END
  PATCH_IF (("%class%" = 14) OR ("%class%" = 15) OR ("%class%" = 18)) BEGIN // cleric-x multis
	SET "max" = 1
	SET "total" = "%total%" + 2 + ("%level1%" / 4)
  END
  PATCH_IF ("%class%" = 8) BEGIN // x-cleric multis
	SET "max" = 1
	SET "total" = "%total%" + 2 + ("%level2%" / 4)
  END
  PATCH_IF ("%class%" = 17) BEGIN // x-x-cleric multis
	SET "max" = 1
	SET "total" = "%total%" + 2 + ("%level3%" / 4)
  END
  PATCH_IF ("%class%" = 16) BEGIN // x-druid multis
	SET "max" = 1
	SET "total" = "%total%" + 2 + ("%level2%" / 4)
  END
  PATCH_IF (("%class%" = 9) OR ("%class%" = 13) OR ("%class%" = 15)) BEGIN // x-thief multis
	SET "max" = 1
	SET "total" = "%total%" + 2 + ("%level2%" / 4)
  END
  PATCH_IF ("%class%" = 10) BEGIN // x-x-thief multis
	SET "max" = 1
	SET "total" = "%total%" + 2 + ("%level3%" / 4)
  END
  PATCH_IF ("%class%" = 16) BEGIN // x-ranger multis
	SET "max" = 2
	SET "total" = "%total%" + 4 + ("%level2%" / 3)
  END
  PATCH_IF ((("%class%" > 6) AND ("%class%" < 11)) OR ("%class%" = 16) OR ("%class%" = 17) ) BEGIN // fighter-x multis
	PATCH_IF (("%dual%" = 1) OR ("%mgm%" = 1)) BEGIN
	  SET "max" = 5
	END ELSE BEGIN
	  SET "max" = 2
	END
	SET "total" = "%total%" + 4 + ("%level1%" / 3)
  END
END
PATCH_PRINT "%SOURCE_FILE% has max %max% and total %total%"
// now to check items and assign profs
READ_SHORT ("%itm_slot_off%" + 0x4c) "equipped" // always give priority to equipped weapon
PATCH_IF (("%equipped%" >= 0) AND ("%equipped%" < 5)) BEGIN // if valid reference
  READ_SHORT ("%itm_slot_off%" + 0x12 + ("%equipped%" * 0x02)) "wpn_idx"
  PATCH_IF ("%wpn_idx%" != 0xffff) BEGIN
	READ_ASCII ("%itm_off%" +		("%wpn_idx%" * 0x14)) "item_name"
	INNER_PATCH_FILE ~%item_name%.itm~ BEGIN

	  PATCH_IF (SOURCE_SIZE > 0) BEGIN
		SET "exists" = 1
		READ_BYTE 0x31 "prof"
	  END

	END
  END
END
// now for other available weapons
FOR (index = 0; index < 4; index = index + 1) BEGIN // go through weapons until last one or out of stars
  SET "exists" = 0
  PATCH_IF ("%equipped%" != "%index%") BEGIN // skip equipped weapon as already addressed above
	READ_SHORT ("%itm_slot_off%" + 0x12 + ("%index%" * 0x02)) "wpn_idx"
	PATCH_IF ("%wpn_idx%" != 0xffff) BEGIN // if valid reference
	  READ_ASCII ("%itm_off%" +		("%wpn_idx%" * 0x14)) "item_name"
	  INNER_PATCH_FILE ~%item_name%.itm~ BEGIN

		PATCH_IF (SOURCE_SIZE > 0) BEGIN
		  READ_BYTE 0x31 "prof_current"
		  PATCH_IF (("%prof_current%" != "%prof%")  AND
					("%prof_current%" != "%prof0%") AND
					("%prof_current%" != "%prof1%") AND
					("%prof_current%" != "%prof2%") AND
					("%prof_current%" != "%prof3%")) BEGIN // only set exists if unique
			SET "exists" = 1
			PATCH_IF ("%index%" = 0) BEGIN
			  SET "prof0" = "%prof_current%"
			END ELSE
			PATCH_IF ("%index%" = 1) BEGIN
			  SET "prof1" = "%prof_current%"
			END ELSE
			PATCH_IF ("%index%" = 2) BEGIN
			  SET "prof2" = "%prof_current%"
			END ELSE BEGIN
			  SET "prof3" = "%prof_current%"
			END
		  END
		END

	  END
	END
  END
END // closes for loop
FOR (index = 0; ((index < 5) AND (total > 0)); index = index + 1) BEGIN
  PATCH_IF ("%index%" = 0) BEGIN
	SET "prof_current" = "prof"
  END ELSE
  PATCH_IF ("%index%" = 1) BEGIN
	SET "prof_current" = "prof0"
  END ELSE
  PATCH_IF ("%index%" = 2) BEGIN
	SET "prof_current" = "prof1"
  END ELSE
  PATCH_IF ("%index%" = 2) BEGIN
	SET "prof_current" = "prof2"
  END ELSE BEGIN
	SET "prof_current" = "prof3"
  END
  PATCH_IF ("%prof_current%" != 255) BEGIN
	SET "new_fx" = "%new_fx%" + 1
	INSERT_BYTES ("%fx_off%") (0x30 + ("%fx_type%" * 0xd8))
	  WRITE_SHORT ("%fx_off%" +		("%fx_type%" * 0x08)) 233
	PATCH_IF ("%total%" < "%max%") BEGIN
	  WRITE_LONG  ("%fx_off%" + 0x04 + ("%fx_type%" * 0x10)) "%total%" // number of stars
	  SET "total" = 0
	END ELSE BEGIN
	  WRITE_LONG  ("%fx_off%" + 0x04 + ("%fx_type%" * 0x10)) "%max%" // number of stars
	  SET "total" = ("%total%" - "%max%")
	END
	  WRITE_LONG  ("%fx_off%" + 0x08 + ("%fx_type%" * 0x10)) "%prof_current%" // prof
	  WRITE_BYTE  ("%fx_off%" + 0x0c + ("%fx_type%" * 0x10)) 9		// timing instant/permanent
	  WRITE_BYTE  ("%fx_off%" + 0x12 + ("%fx_type%" * 0x12)) 100	  // probability
  END
END
PATCH_IF ("%new_fx%" > 0) BEGIN // final offset adjustments
  READ_LONG 0x2a0 "known_off"
  READ_LONG 0x2a8 "meminfo_off"
  READ_LONG 0x2b0 "mem_off"
  READ_LONG 0x2b8 "slot_off"
  READ_LONG 0x2c8 "fx_num"
  SET "offset" = ("%new_fx%" * (0x30 + ("%fx_type%" * 0xd8)))
  PATCH_IF ("%known_off%" >= "%fx_off%") BEGIN
	WRITE_LONG 0x2a0 ("%known_off%" + "%offset%")
  END
  PATCH_IF ("%meminfo_off%" >= "%fx_off%") BEGIN
	WRITE_LONG 0x2a8 ("%meminfo_off%" + "%offset%")
  END
  PATCH_IF ("%mem_off%" >= "%fx_off%") BEGIN
	WRITE_LONG 0x2b0 ("%mem_off%" + "%offset%")
  END
  PATCH_IF ("%itm_slot_off%" >= "%fx_off%") BEGIN
	WRITE_LONG 0x2b8 ("%itm_slot_off%" + "%offset%")
  END
  PATCH_IF ("%itm_off%" >= "%fx_off%") BEGIN
	WRITE_LONG 0x2bc ("%itm_off%" + "%offset%")
  END
  WRITE_LONG 0x2c8 ("%fx_num%" + "%new_fx%")
END
 END
 BUT_ONLY_IF_IT_CHANGES

Link to comment

Much thanks :)

 

Lots of similarities, as to be expected :)

 

Stuff I was doing differently:

  • Break everything down an additional level by kit.
  • Read equipped weapon's proficiency type and store it as a variable, then assign "legal" proficiencies in the libraries with priority given to equipped stuff.
  • Give two-weapon style the most weight, as the penalties negated by the first two points are greater than non-proficiency for anyone except single-class mages (who can't use the style anyway) and multiple-attack fighters (where the general solution depends on total thac0).
  • Assign leftover proficiencies that don't match an equipped item on a most-damaging down basis with a random number element (while you and I know that mages are generally better off with darts than slings, EquipMostDamagingMelee and its ilk don't).

Preliminaries to ensure that kits and such can be read correctly, some of which is fixpack retread and none of which has been debugged:

ALLOW_MISSING
~amlich01.cre~
~amtmag01.cre~
~chang01.cre~
~chang02.cre~
~deck615.cre~
~demilich.cre~
~fsmage03.cre~
~gorgua01.cre~
~gromg01.cre~
~gromg04.cre~
~gromg06.cre~
~gromg07.cre~
~gromg09.cre~
~gromg10.cre~
~gromg12.cre~
~gromg14.cre~
~hgmag01.cre~
~hgmag02.cre~
~sarkis02.cre~
~sarkis03.cre~
~sendai6.cre~
~senlich.cre~
~sevdru01.cre~
~ysmage02.cre~

~sendai4.bcs~

BEGIN  ~Attaining proficiency with the Spork +5 and the Hoe of Destruction~


///////////////////////////////////////////////////////////////////////
// eliminating spurious kits                                         //
///////////////////////////////////////////////////////////////////////

COPY_EXISTING ~arnwar09.cre~ ~override~ // Shadow Thief: cleric/mage multi with kit: conjurer (seems unnecessary, casts divinations)
             ~c6coran.cre~  ~override~ // Coran: fighter/thief multi with kit: invoker (seems a goof)
             ~deathkni.cre~ ~override~ // Demon Knight: fighter18/mage1 multi with kit: conjurer (ForceSpells cast at level one)
             ~deck615.cre~  ~override~ // Demon Knight: fighter18/mage1 multi with kit: conjurer (ForceSpells cast at level one)
          // ~dpplay01.cre~ ~override~ // < -1>: deathmatch cruft, NO_CLASS stalker
          // ~dpplay02.cre~ ~override~ // < -1>: deathmatch cruft, NO_CLASS stalker
          // ~e34.cre~      ~override~ // Coran: the Invoker again, unused cruft
             ~lissa.cre~    ~override~ // Lissa: cleric with kit: illusionist (gnome)
             ~maevar.cre~   ~override~ // Maevar: mage/thief multi with kit: conjurer (can't cast any of his scripted spells anyway)
             ~majan.cre~    ~override~ // Ma Jansen: Innocent illusionist, mostly priest spells known and scripts that don't cast them
          // ~mdk2doc.cre~  ~override~ // Doc 'cheezy' Hawkins: fighter with kit: conjurer
          // ~mdk2kurt.cre~ ~override~ // The Infamous Kurt: fighter with kit: conjurer
          // ~mdk2max.cre~  ~override~ // Arny Max: fighter with kit: conjurer
             ~pbhunt03.cre~ ~override~ // Bounty Hunter: yuan-ti LONG_SWORD conjurer, casts True Sight
             ~pwarden.cre~  ~override~ // Warden: fighter18/mage1 multi with kit: conjurer (ForceSpells cast at level one)
             ~sarkis02.cre~ ~override~ // Fighter: fighter with kit: assassin
             ~sarkis03.cre~ ~override~ // Fighter: fighter with kit: assassin
             ~sevdru01.cre~ ~override~ // Alatelo De Bonito: innocent enchanter, no spells nor spellcasting scripts
             ~uddeath.cre~  ~override~ // Demon Knight: fighter18/mage1 multi with kit: conjurer (ForceSpells cast at level one)
             ~uddeath2.cre~ ~override~ // Demon Knight: fighter18/mage1 multi with kit: conjurer (ForceSpells cast at level one)
             ~uhrang01.cre~ ~override~ // Merella: ranger with kit: illusionist
             ~vaelag.cre~   ~override~ // Vaelag: fighter with kit: illusionist (gnome)
             // mages who are copy/paste conjurers below
             ~amlich01.cre~ ~override~ // Vongoethe: (amlich02.bcs casts True Sight)
          // ~ammag01.cre~  ~override~ // Mage: (Amkethran cutscene)
             ~amtmag01.cre~ ~override~ // Tethyrian Battlemage: (gpmage2.bcs casts True Sight)
          // ~ar18mage.cre~ ~override~ // Mage: (north forest encounter) (no divinations)
          // ~bdturm03.cre~ ~override~ // Turmish Sorceress: (bard stronghold plot) (no divinations)
             ~bodtan.cre~   ~override~ // Tanova: (mage16c.bcs casts True Sight)
          // ~breg01.cre~   ~override~ // Visaj: (no divinations)
             ~c6harp.cre~   ~override~ // Malchor Harpell:  (mage18a.bcs casts True Sight)
          // ~corneil.cre~  ~override~ // Corneil: (DPLAYER.bcs, nice script you punk)
          // ~cowenf1.cre~  ~override~ // Cowled Enforcer: (no divinations)
             ~cowenf3.cre~  ~override~ // Cowled Enforcer: (cowenf03.bcs casts True Sight)
             ~cowenf4.cre~  ~override~ // Cowled Enforcer: (cowenf04.bcs casts True Sight)
          // ~cowled.cre~   ~override~ // Cowled Wizard: (no divinations, obviously unneeded to monitor the use of magic in Amn)
          // ~dadrow16.cre~ ~override~ // Drow: (no divinations)
             ~dadrow2.cre~  ~override~ // Drow Servant: (mage14c.bcs casts True Sight)
          // ~dario.cre~    ~override~ // Dario Thet: (no divinations)
             ~dcowl1.cre~   ~override~ // Rayic Gethras: (mage14c.bcs casts True Sight)
             ~demilich.cre~ ~override~ // Demi-Lich: (no divinations, but a Kangaxx copy)
             ~drow06.cre~   ~override~ // Drow: (mage14d.bcs casts True Sight)
          // ~e35.cre~      ~override~ // Edwin: (unused E3 cruft)
          // ~edwin11.cre~  ~override~ // Edwin's meant to be a Red Wizard
          // ~edwin12.cre~  ~override~ // Edwin's meant to be a Red Wizard
          // ~edwin13.cre~  ~override~ // Edwin's meant to be a Red Wizard
          // ~edwin15.cre~  ~override~ // Edwin's meant to be a Red Wizard
          // ~edwin7.cre~   ~override~ // Edwin's meant to be a Red Wizard
          // ~edwin9.cre~   ~override~ // Edwin's meant to be a Red Wizard
          // ~firmag01.cre~ ~override~ // Conster: (no divinations)
          // ~fsmage01.cre~ ~override~ // Mage: (no divinations)
          // ~fsmage02.cre~ ~override~ // Mage: (no divinations)
             ~fsmage03.cre~ ~override~ // Mage: (mage18a.bcs casts True Sight)
             ~gaius.cre~    ~override~ // Gaius: (mage14c.bcs casts True Sight)
          // ~genmag01.cre~ ~override~ // Mage :(no divinations)
          // ~gmage14.cre~  ~override~ // Mekrath: (no divinations)
          // ~gorsku01.cre~ ~override~ // Flaming Skull: (no divinations)
          // ~gpmage1.cre~  ~override~ // N'ashtar: (no divinations)
             ~grvlch01.cre~ ~override~ // Lich: (mage20b.bcs casts True Sight)
             ~hgmag01.cre~  ~override~ // Fire Giant Mage:  (mage18b.bcs casts True Sight)
             ~hgmag02.cre~  ~override~ // Fire Giant Mage:  (mage18c.bcs casts True Sight)
          // ~hgsku01.cre~  ~override~ // Flaming Skull: (no divinations)
             ~hldemi.cre~   ~override~ // Kangaxx: the Demi-Lich
             ~hlkang.cre~   ~override~ // Kangaxx: the Lich (mage18d.bcs casts True Sight)
             ~hllayen.cre~  ~override~ // Layene: (mage20b.bcs casts True Sight)
             ~hlshang.cre~  ~override~ // Shangalar: (mage20c.bcs casts True Sight)
             ~hlsion.cre~   ~override~ // Sion: (hlsion.bcs casts True Sight)
             ~jade3.cre~    ~override~ // Jeremon: (mage12c.bcs casts True Sight)
          // ~jaga3.cre~    ~override~ // Nadinal: (no divinations)
             ~jahei3.cre~   ~override~ // Harper: (mage12c.bcs casts True Sight)
          // ~jamage1.cre~  ~override~ // Gracien: (no divinations)
          // ~jamage2.cre~  ~override~ // Malacazar: (no divinations)
             ~jarev3.cre~   ~override~ // Harper: (mage12c.bcs casts True Sight)
             ~jarlich.cre~  ~override~ // Deirex: (mage18d.bcs casts True Sight)
             ~lich01.cre~   ~override~ // Lich: (mage18d.bcs casts True Sight)
          // ~mage14a.cre~  ~override~ // Zyntris: (no divinations) (unused)
          // ~mage14b.cre~  ~override~ // Zyntris: (unused)
          // ~mage14c.cre~  ~override~ // Zyntris: (mage14c.bcs casts True Sight) (unused)
          // ~mage14m.cre~  ~override~ // Zyntris: (unused)
          // ~mage16a.cre~  ~override~ // Zyntris: (unused)
          // ~mage16b.cre~  ~override~ // Zyntris: (unused)
             ~mage16c.cre~  ~override~ // Khollynnus Paac: (When Cowls Attack! version)(mage16c.bcs casts True Sight)
          // ~mage16m.cre~  ~override~ // Zyntris: (unused)
             ~mage18a.cre~  ~override~ // Cowled Wizard: (mage18a.bcs casts True Sight)
          // ~mage18b.cre~  ~override~ // Zyntris: (unused) (mage18b.bcs casts True Sight)
          // ~mage18c.cre~  ~override~ // Zyntris: (unused) (mage18c.bcs casts True Sight)
          // ~mage18d.cre~  ~override~ // Zyntris: (unused) (mage18d.bcs casts True Sight)
          // ~mage18e.cre~  ~override~ // Zyntris: (unused) (mage18e.bcs casts True Sight)
          // ~mage18y.cre~  ~override~ // Zyntris: (mage18y.bcs casts True Sight)
             ~mage18z.cre~  ~override~ // Zallanora: (mage18z.bcs casts True Sight)
          // ~mekrat.cre~   ~override~ // Mekrath: (no divinations)
          // ~mgbill01.cre~ ~override~ // William 'Bill' Williamson: (no divinations)
             ~mgkhol01.cre~ ~override~ // Khollynnus Paac: (mage18a.bcs casts True Sight)
          // ~mgteos01.cre~ ~override~ // Teos: (no divinations)
             ~obshal05.cre~ ~override~ // Kayardi: (mage16c.bcs casts True Sight)
          // ~pirmur07.cre~ ~override~ // Vadek: (no divinations)
          // ~ppaph2.cre~   ~override~ // Aphril: (no divinations)
          // ~ppaphril.cre~ ~override~ // Aphril: (no divinations)
             ~ppcowled.cre~ ~override~ // Perth the Adept: (mage18b.bcs casts True Sight)
          // ~ppdra2.cre~   ~override~ // Dradeel: (no divinations)
          // ~ppdradee.cre~ ~override~ // Dradeel: (no divinations)
          // ~ppsanik.cre~  ~override~ // Sanik: (no divinations)
             ~ppwanev.cre~  ~override~ // Wanev: (mage18d.bcs casts True Sight)
             ~ppwanev2.cre~ ~override~ // Wanev: (mage18d.bcs casts True Sight)
             ~ppworker.cre~ ~override~ // Lonk the Sane: (mage18a.bcs casts True Sight)
          // ~redrad01.cre~ ~override~ // Dradeel: (no divinations)
          // ~rumar01.cre~  ~override~ // Umar: (no divinations)
          // ~sarmist.cre~  ~override~ // Cold Mistress: (no divinations)
             ~senlich.cre~  ~override~ // Odamaron: (mage18d.bcs casts True Sight)
          // ~stmage.cre~   ~override~ // Shadow Thief: (no divinations)
          // ~tanwiz02.cre~ ~override~ // Mage: (no divinations)
          // ~tanwiz03.cre~ ~override~ // Mage: (no divinations)
          // ~tanwiz04.cre~ ~override~ // Mage: (no divinations)
          // ~terrece.cre~  ~override~ // Terrece: (mage12c.bcs casts True Sight)
          // ~trcut05.cre~  ~override~ // Lady Lilith Lurraxol: (no divinations)
          // ~trfued01.cre~ ~override~ // Lady Lilith Lurraxol: (no divinations)
             ~uddoor05.cre~ ~override~ // Drow Wizard: (mage18a.bcs casts True Sight)
             ~uddrow19.cre~ ~override~ // Drow: (mage14d.bcs casts True Sight)
             ~udtrap02.cre~ ~override~ // Raevilin Strathi: (mage18b.bcs casts True Sight)
             ~udtrap04.cre~ ~override~ // Alchra Diagott: (mage18d.bcs casts True Sight)
             ~udvith.cre~   ~override~ // Vithal: (changes script to mage18z.bcs)
          // ~vara.cre~     ~override~ // Vara Fentan: (no divinations, barely a mage anyway)
             ~wyvmag14.cre~ ~override~ // Wyvern Cultist:  (mage14c.bcs casts True Sight)
          // ~yarmy03.cre~  ~override~ // Mage: (Yaga-Shura fracas) (no divinations)
             ~ysmage02.cre~ ~override~ // Yaga-Shura Mage: (mage16c.bcs casts True Sight)
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   WRITE_LONG 0x0244 0x00000000 // no kit
 END
BUT_ONLY_IF_IT_CHANGES



////////////////////////////////////////////////////////////////////////
// various errors in flags at 0x10 in the .cre                        //
////////////////////////////////////////////////////////////////////////

// these creatures have dualled from every class
COPY_EXISTING ~akae.cre~     ~override~ // Akae
             ~elekuo01.cre~ ~override~ // Kuo-Toa Warrior
             ~elekuo02.cre~ ~override~ // Kuo-Toa Whip
             ~gorkuo01.cre~ ~override~ // Kuo-Toa Warrior
             ~gorkuo02.cre~ ~override~ // Kuo-Toa Archer
             ~gorkuo03.cre~ ~override~ // Kuo-Toa Priest
             ~gorkuo05.cre~ ~override~ // Kuo-Toa Whip
             ~kuolie01.cre~ ~override~ // Kuo-Toa Lieutenant
             ~kuomag01.cre~ ~override~ // Kuo-Toa Wizard
             ~kuomon01.cre~ ~override~ // Kuo-Toa Monitor
             ~kuopri01.cre~ ~override~ // Kuo-Toa Priest
             ~kuotoa01.cre~ ~override~ // Kuo-Toa Warrior
             ~kuowar01.cre~ ~override~ // Kuo-Toa Warrior
             ~kuowhi01.cre~ ~override~ // Kuo-Toa Whip
             ~nalbarg.cre~  ~override~ // Barg
             ~udkuo01.cre~  ~override~ // Kuo-Toa Leader
             ~udkuo02.cre~  ~override~ // Master Whip
             ~udprince.cre~ ~override~ // Kuo-Toa Prince
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   WRITE_LONG 0x10 0x00000000 // no flags set
 END
BUT_ONLY_IF_IT_CHANGES

// these creatures have all the flags
COPY_EXISTING ~elfirl01.cre~ ~override~ // Lesser Fire Elemental
             ~sahzomb.cre~  ~override~ // Sea Zombie
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   WRITE_LONG 0x10 0x00000000 // no flags set
 END
BUT_ONLY_IF_IT_CHANGES

// single class creatures with a dual-class flag set
COPY_EXISTING ~firkra02.cre~ ~override~ // Firkraag
             ~fsdragon.cre~ ~override~ // Dragon
             ~gorsal.cre~   ~override~ // Saladrex
          // ~ppdrimo.cre~  ~override~ // Imoen (dream version)
          // ~ppdrimov.cre~ ~override~ // Imoen (dream version)
          // ~ppimoen.cre~  ~override~ // Imoen (dream version)
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   WRITE_LONG 0x10 0x00000000 // no flags set
 END
BUT_ONLY_IF_IT_CHANGES



///////////////////////////////////////////////////////////////////////
// adjusting kit notation to use corrected kit .ids                  //
///////////////////////////////////////////////////////////////////////

// regexp should be equivalent to:
/////////////////////////////////////////////
// COPY_EXISTING ~bhelm.cre~    ~override~ // Guardian Vottnar
//               ~chalcy02.cre~ ~override~ // Favored of Cyric
//               ~disrup01.cre~ ~override~ // Wizard Slayer
//               ~gaelan.cre~   ~override~ // Gaelan Bayle
//               ~genth01.cre~  ~override~ // Thief
//               ~genth02.cre~  ~override~ // Thief
//               ~gorwom02.cre~ ~override~ // The Huntress
//               ~jaga2.cre~    ~override~ // Kail
//               ~jaga4.cre~    ~override~ // Iko
//               ~keldor9.cre~  ~override~ // Keldorn
//               ~meronia.cre~  ~override~ // Meronia
//               ~pace.cre~     ~override~ // Pace
//               ~parfig16.cre~ ~override~ // Jalin Tix
//               ~parthf.cre~   ~override~ // Alnarow
//               ~ysgp02.cre~   ~override~ // Merlinious
//               ~ysgp03.cre~   ~override~ // Tibbit
/////////////////////////////////////////////

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   PATCH_IF ("%SOURCE_RES%" STRING_COMPARE_CASE "modcreat") THEN BEGIN
     READ_LONG      0x0244 "kit"
     READ_BYTE      0x0273 "class"
// generalist only significant for PCs gaining extra spell slots due to kitting
/*
     PATCH_IF            ("class" = 0x01)     THEN BEGIN
       // mages
       PATCH_IF          ("kit" = 0x40000000) THEN BEGIN
         WRITE_LONG 0x0244 0x00000000
       END
     END ELSE
*/
     PATCH_IF            ("class" = 0x02)     THEN BEGIN
       // fighters
       PATCH_IF          ("kit" = 0x00010000) THEN BEGIN
         WRITE_LONG 0x0244 0x40010000
       END ELSE PATCH_IF ("kit" = 0x00020000) THEN BEGIN
         WRITE_LONG 0x0244 0x40020000
       END ELSE PATCH_IF ("kit" = 0x00040000) THEN BEGIN
         WRITE_LONG 0x0244 0x40030000
       END
     END ELSE PATCH_IF   ("class" = 0x03)     THEN BEGIN
       // clerics
       PATCH_IF          ("kit" = 0x00000100) THEN BEGIN
         WRITE_LONG 0x0244 0x40130000
       END ELSE PATCH_IF ("kit" = 0x00000200) THEN BEGIN
         WRITE_LONG 0x0244 0x40140000
       END ELSE PATCH_IF ("kit" = 0x00000400) THEN BEGIN
         WRITE_LONG 0x0244 0x40150000
       END
     END ELSE PATCH_IF   ("class" = 0x04)     THEN BEGIN
       // thieves
       PATCH_IF          ("kit" = 0x00000004) THEN BEGIN
         WRITE_LONG 0x0244 0x400a0000
       END ELSE PATCH_IF ("kit" = 0x00000008) THEN BEGIN
         WRITE_LONG 0x0244 0x400b0000
       END PATCH_IF      ("kit" = 0x00000010) THEN BEGIN
         WRITE_LONG 0x0244 0x400c0000
       END
     END ELSE PATCH_IF   ("class" = 0x05)     THEN BEGIN
       // bards
       PATCH_IF          ("kit" = 0x00000020) THEN BEGIN
         WRITE_LONG 0x0244 0x400d0000
       END ELSE PATCH_IF ("kit" = 0x00000040) THEN BEGIN
         WRITE_LONG 0x0244 0x400e0000
       END ELSE PATCH_IF ("kit" = 0x00000080) THEN BEGIN
         WRITE_LONG 0x0244 0x400f0000
       END
     END ELSE PATCH_IF   ("class" = 0x06)     THEN BEGIN
       // paladins
       PATCH_IF          ("kit" = 0x00080000) THEN BEGIN
         WRITE_LONG 0x0244 0x40040000
       END ELSE PATCH_IF ("kit" = 0x00100000) THEN BEGIN
         WRITE_LONG 0x0244 0x40050000
       END ELSE PATCH_IF ("kit" = 0x00200000) THEN BEGIN
         WRITE_LONG 0x0244 0x40060000
       END
     END ELSE PATCH_IF   ("class" = 0x07)     THEN BEGIN
       // fighter/mage
       PATCH_IF          ("kit" = 0x40000000) THEN BEGIN
         WRITE_LONG 0x0244 0x00000000
       END ELSE PATCH_IF ("kit" = 0x00010000) THEN BEGIN
         WRITE_LONG 0x0244 0x40010000
       END ELSE PATCH_IF ("kit" = 0x00020000) THEN BEGIN
         WRITE_LONG 0x0244 0x40020000
       END ELSE PATCH_IF ("kit" = 0x00040000) THEN BEGIN
         WRITE_LONG 0x0244 0x40030000
       END
     END ELSE PATCH_IF   ("class" = 0x08)     THEN BEGIN
       // fighter/cleric
       PATCH_IF          ("kit" = 0x00010000) THEN BEGIN
         WRITE_LONG 0x0244 0x40010000
       END ELSE PATCH_IF ("kit" = 0x00020000) THEN BEGIN
         WRITE_LONG 0x0244 0x40020000
       END ELSE PATCH_IF ("kit" = 0x00040000) THEN BEGIN
         WRITE_LONG 0x0244 0x40030000
       END ELSE PATCH_IF ("kit" = 0x00000100) THEN BEGIN
         WRITE_LONG 0x0244 0x40130000
       END ELSE PATCH_IF ("kit" = 0x00000200) THEN BEGIN
         WRITE_LONG 0x0244 0x40140000
       END ELSE PATCH_IF ("kit" = 0x00000400) THEN BEGIN
         WRITE_LONG 0x0244 0x40150000
       END
     END ELSE PATCH_IF   ("class" = 0x09)     THEN BEGIN
       // fighter/thief
       PATCH_IF          ("kit" = 0x00010000) THEN BEGIN
         WRITE_LONG 0x0244 0x40010000
       END ELSE PATCH_IF ("kit" = 0x00020000) THEN BEGIN
         WRITE_LONG 0x0244 0x40020000
       END ELSE PATCH_IF ("kit" = 0x00040000) THEN BEGIN
         WRITE_LONG 0x0244 0x40030000
       END ELSE PATCH_IF ("kit" = 0x00000004) THEN BEGIN
         WRITE_LONG 0x0244 0x400a0000
       END ELSE PATCH_IF ("kit" = 0x00000008) THEN BEGIN
         WRITE_LONG 0x0244 0x400b0000
       END ELSE PATCH_IF ("kit" = 0x00000010) THEN BEGIN
         WRITE_LONG 0x0244 0x400c0000
       END
     END ELSE PATCH_IF   ("class" = 0x0a)     THEN BEGIN
       // fighter/mage/thief
       PATCH_IF          ("kit" = 0x40000000) THEN BEGIN
         WRITE_LONG 0x0244 0x00000000
       END
     END ELSE PATCH_IF   ("class" = 0x0b)     THEN BEGIN
       // druids
       PATCH_IF          ("kit" = 0x08000000) THEN BEGIN
         WRITE_LONG 0x0244 0x40100000
       END ELSE PATCH_IF ("kit" = 0x10000000) THEN BEGIN
         WRITE_LONG 0x0244 0x40110000
       END ELSE PATCH_IF ("kit" = 0x20000000) THEN BEGIN
         WRITE_LONG 0x0244 0x40120000
       END
     END ELSE PATCH_IF   ("class" = 0x0c)     THEN BEGIN
       // ranger
       PATCH_IF          ("kit" = 0x80000000) THEN BEGIN
         WRITE_LONG 0x0244 0x40070000
       END ELSE PATCH_IF ("kit" = 0x00010000) THEN BEGIN
         WRITE_LONG 0x0244 0x40080000
       END ELSE PATCH_IF ("kit" = 0x00020000) THEN BEGIN
         WRITE_LONG 0x0244 0x40090000
       END
     END ELSE PATCH_IF   ("class" = 0x0d)     THEN BEGIN
       // mage/thief
       PATCH_IF          ("kit" = 0x00000004) THEN BEGIN
         WRITE_LONG 0x0244 0x400a0000
       END ELSE PATCH_IF ("kit" = 0x00000008) THEN BEGIN
         WRITE_LONG 0x0244 0x400b0000
       END PATCH_IF      ("kit" = 0x00000010) THEN BEGIN
         WRITE_LONG 0x0244 0x400c0000
       END ELSE PATCH_IF ("kit" = 0x40000000) THEN BEGIN
         WRITE_LONG 0x0244 0x00000000
       END
     END ELSE PATCH_IF   ("class" = 0x0e)     THEN BEGIN
       // cleric/mage
       PATCH_IF          ("kit" = 0x40000000) THEN BEGIN
         WRITE_LONG 0x0244 0x00000000
       END ELSE PATCH_IF ("kit" = 0x00000100) THEN BEGIN
         WRITE_LONG 0x0244 0x40130000
       END ELSE PATCH_IF ("kit" = 0x00000200) THEN BEGIN
         WRITE_LONG 0x0244 0x40140000
       END ELSE PATCH_IF ("kit" = 0x00000400) THEN BEGIN
         WRITE_LONG 0x0244 0x40150000
       END
     END ELSE PATCH_IF   ("class" = 0x0f)     THEN BEGIN
       // cleric/thief
       PATCH_IF          ("kit" = 0x00000100) THEN BEGIN
         WRITE_LONG 0x0244 0x40130000
       END ELSE PATCH_IF ("kit" = 0x00000200) THEN BEGIN
         WRITE_LONG 0x0244 0x40140000
       END ELSE PATCH_IF ("kit" = 0x00000400) THEN BEGIN
         WRITE_LONG 0x0244 0x40150000
       END ELSE PATCH_IF ("kit" = 0x00000008) THEN BEGIN
         WRITE_LONG 0x0244 0x400b0000
       END PATCH_IF      ("kit" = 0x00000010) THEN BEGIN
         WRITE_LONG 0x0244 0x400c0000
       END ELSE PATCH_IF ("kit" = 0x40000000) THEN BEGIN
         WRITE_LONG 0x0244 0x00000000
       END
     END ELSE PATCH_IF   ("class" = 0x10)     THEN BEGIN
       // fighter/druid
       PATCH_IF          ("kit" = 0x00010000) THEN BEGIN
         WRITE_LONG 0x0244 0x40010000
       END ELSE PATCH_IF ("kit" = 0x00020000) THEN BEGIN
         WRITE_LONG 0x0244 0x40020000
       END ELSE PATCH_IF ("kit" = 0x00040000) THEN BEGIN
         WRITE_LONG 0x0244 0x40030000
       END ELSE PATCH_IF ("kit" = 0x08000000) THEN BEGIN
         WRITE_LONG 0x0244 0x40100000
       END ELSE PATCH_IF ("kit" = 0x10000000) THEN BEGIN
         WRITE_LONG 0x0244 0x40110000
       END ELSE PATCH_IF ("kit" = 0x20000000) THEN BEGIN
         WRITE_LONG 0x0244 0x40120000
       END
     END ELSE PATCH_IF   ("class" = 0x11)     THEN BEGIN
       // fighter/mage/cleric multi
       PATCH_IF          ("kit" = 0x40000000) THEN BEGIN
         WRITE_LONG 0x0244 0x00000000
       END
     END ELSE PATCH_IF   ("class" = 0x12)     THEN BEGIN
       // cleric/ranger
       PATCH_IF          ("kit" = 0x00000100) THEN BEGIN
         WRITE_LONG 0x0244 0x40130000
       END ELSE PATCH_IF ("kit" = 0x00000200) THEN BEGIN
         WRITE_LONG 0x0244 0x40140000
       END ELSE PATCH_IF ("kit" = 0x00000400) THEN BEGIN
         WRITE_LONG 0x0244 0x40150000
       END ELSE PATCH_IF ("kit" = 0x80000000) THEN BEGIN
         WRITE_LONG 0x0244 0x40070000
       END ELSE PATCH_IF ("kit" = 0x00010000) THEN BEGIN
         WRITE_LONG 0x0244 0x40080000
       END ELSE PATCH_IF ("kit" = 0x00020000) THEN BEGIN
         WRITE_LONG 0x0244 0x40090000
       END
     END
   END
 END
BUT_ONLY_IF_IT_CHANGES

Link to comment

Specific creatures changes to the cheaty, the bugged, and the exceptionally tweaky (lots of room for growth here)

///////////////////////////////////////////////////////////////////////
// specific creature modifications                                   //
///////////////////////////////////////////////////////////////////////

// Yeanasha (Shadow Thieves vs Bohdi): 16fighter/1thief multi with kit: kensai (has kensai.bcs but no kai assigned)
// getting less than an equivalent PC's kensai bonus because bioware pretty consistently gave kensai
// NPCs bonuses every five levels rather than three/four. Hey, he's chaotic and wearing armor anyway
COPY_EXISTING ~c6yean.cre~   ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
//    WRITE_LONG 0x010 0x00000008
   READ_LONG  0x2a0 "kso"
   PATCH_IF ("kso" = 0x00) THEN BEGIN
     SET "kso" = 0x2d4
     WRITE_LONG  0x2a0 "kso"
   END
   READ_LONG  0x2a4 "ksc"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2ac "smc"
   READ_LONG  0x2b0 "mso"
   PATCH_IF ("mso" = 0x00) THEN BEGIN
     SET "mso" = 0x2d4
     WRITE_LONG  0x2b0 "mso"
   END
   READ_LONG  0x2b4 "msc"
   READ_LONG  0x2b8 "iso"
   PATCH_IF ("iso" = 0x00) THEN BEGIN
     SET "iso" = 0x2d4
     WRITE_LONG  0x2b8 "iso"
   END
   READ_LONG  0x2bc "ilo"
   PATCH_IF ("ilo" = 0x00) THEN BEGIN
     SET "ilo" = 0x2d4
     WRITE_LONG  0x2bc "ilo"
   END
   READ_LONG  0x2c0 "ilc"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x05)
   INSERT_BYTES "fxo" (0x108 * 0x05)
     FOR ("i" = 0x00; "i" < (0x108 * 0x05); "i" += 0x108) BEGIN
       WRITE_LONG  ("fxo" + "i" + 0x1c) 0x09 // perm. after death
       WRITE_SHORT ("fxo" + "i" + 0x24) 0x64 // minimum probability
       WRITE_LONG  ("fxo" + "i" + 0xc4) 0x01 // secondary type
     END
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x08) 0xe9 // opcode: weaponprof
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x14) 0x05 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x18) 0x5b // short sword prof
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x08) 0x49 // opcode: damage bonus
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x14) 0x03 // modifier
     WRITE_LONG   ("fxo" + (0x108 * 0x02) + 0x08) 0xbe // opcode: attack speed factor
     WRITE_LONG   ("fxo" + (0x108 * 0x03) + 0x14) 0x03 // modifier
     WRITE_LONG   ("fxo" + (0x108 * 0x03) + 0x08) 0x36 // opcode: thac0 bonus
     WRITE_LONG   ("fxo" + (0x108 * 0x03) + 0x14) 0x03 // modifier
     WRITE_LONG   ("fxo" + (0x108 * 0x04) + 0x08) 0x00 // opcode: ac bonus
     WRITE_LONG   ("fxo" + (0x108 * 0x04) + 0x14) 0x02 // modifier
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + (0x108 * 0x05))
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + (0x108 * 0x05))
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + (0x108 * 0x05))
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + (0x108 * 0x05))
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + (0x108 * 0x05))
   END
   INSERT_BYTES "kso" 0x0c
     WRITE_ASCIIT ("kso" + 0x00) ~spcl144~
     WRITE_SHORT  ("kso" + 0x08) 0x00 // level
     WRITE_SHORT  ("kso" + 0x0a) 0x02 // type: innate
   WRITE_LONG   0x2a4 ("ksc" + 0x01)
   PATCH_IF ("smo" >= "kso") THEN BEGIN
     SET "smo" = ("smo" + 0x0c)
     WRITE_LONG 0x2a8 "smo"
   END
   PATCH_IF ("mso" >= "kso") THEN BEGIN
     SET "mso" = ("mso" + 0x0c)
     WRITE_LONG 0x2b0 "mso"
   END
   PATCH_IF ("iso" >= "kso") THEN BEGIN
     SET "iso" = ("iso" + 0x0c)
     WRITE_LONG 0x2b8 "iso"
   END
   PATCH_IF ("ilo" >= "kso") THEN BEGIN
     SET "ilo" = ("ilo" + 0x0c)
     WRITE_LONG 0x2bc "ilo"
   END
   PATCH_IF ("fxo" >= "kso") THEN BEGIN
     SET "fxo" = ("fxo" + 0x0c)
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_SHORT     ("smo" + 0x102) "nmu" // number memorizable
   WRITE_SHORT    ("smo" + 0x102) "nmu" + 0x03
   READ_SHORT     ("smo" + 0x104) "nmm" // number memorizable
   WRITE_SHORT    ("smo" + 0x104) "nmm" + 0x03
   READ_LONG      ("smo" + 0x10c) "nmc" // count
   WRITE_LONG     ("smo" + 0x10c) "nmc" + 0x03
   INSERT_BYTES "mso" (0x0c * 0x03)
     WRITE_ASCIIT ("mso" + 0x00) ~spcl144~
     WRITE_LONG   ("mso" + 0x08) 0x01
     WRITE_ASCIIT ("mso" + 0x0c) ~spcl144~
     WRITE_LONG   ("mso" + 0x14) 0x01
     WRITE_ASCIIT ("mso" + 0x18) ~spcl144~
     WRITE_LONG   ("mso" + 0x20) 0x01
   WRITE_LONG   0x2b4 ("msc" + 0x03)
   PATCH_IF ("kso" >= "mso") THEN BEGIN
     SET "kso" = ("kso" + (0x0c * 0x03))
     WRITE_LONG 0x2a0 "kso"
   END
   PATCH_IF ("smo" >= "mso") THEN BEGIN
     SET "smo" = ("smo" + (0x0c * 0x03))
     WRITE_LONG 0x2a8 "smo"
   END
   PATCH_IF ("iso" >= "mso") THEN BEGIN
     SET "iso" = ("iso" + (0x0c * 0x03))
     WRITE_LONG 0x2b8 "iso"
   END
   PATCH_IF ("ilo" >= "mso") THEN BEGIN
     SET "ilo" = ("ilo" + (0x0c * 0x03))
     WRITE_LONG 0x2bc "ilo"
   END
   PATCH_IF ("fxo" >= "mso") THEN BEGIN
     SET "fxo" = ("fxo" + (0x0c * 0x03))
     WRITE_LONG 0x2c4 "fxo"
   END
 END
BUT_ONLY_IF_IT_CHANGES

// Angelo: fighter/thief multi with kit: feralan (has called shot but no archer bonus)
COPY_EXISTING ~chang01.cre~  ~override~
             ~chang02.cre~  ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x03)
   INSERT_BYTES "fxo" (0x108 * 0x03)
     FOR ("i" = 0x00; "i" < (0x108 * 0x03); "i" += 0x108) BEGIN
       WRITE_LONG  ("fxo" + "i" + 0x08) 0xe9 // opcode: weaponprof
       WRITE_LONG  ("fxo" + "i" + 0x1c) 0x09 // perm. after death
       WRITE_SHORT ("fxo" + "i" + 0x24) 0x64 // minimum probability
       WRITE_LONG  ("fxo" + "i" + 0xc4) 0x01 // secondary type
     END
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x14) 0x05 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x18) 0x69 // shortbow prof
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x14) 0x02 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x18) 0x5b // shortsword prof
     WRITE_LONG   ("fxo" + (0x108 * 0x02) + 0x14) 0x01 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x02) + 0x18) 0x71 // single weapon prof
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + (0x108 * 0x03))
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + (0x108 * 0x03))
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + (0x108 * 0x03))
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + (0x108 * 0x03))
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + (0x108 * 0x03))
   END
 END
BUT_ONLY_IF_IT_CHANGES

// Aurumach Rilmani: mage with kit: berserker (has enrage, not scripted to cast it)
COPY_EXISTING ~gorgua01.cre~ ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x01)
   INSERT_BYTES   "fxo" (0x108)
     WRITE_LONG  ("fxo" + 0x08) 0xe9 // opcode: weaponprof
     WRITE_LONG  ("fxo" + 0x14) 0x02 // stars
     WRITE_LONG  ("fxo" + 0x18) 0x73 // club prof
     WRITE_LONG  ("fxo" + 0x1c) 0x09 // perm. after death
     WRITE_SHORT ("fxo" + 0x24) 0x64 // minimum probability
     WRITE_LONG  ("fxo" + 0xc4) 0x01 // secondary type
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + 0x108)
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + 0x108)
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + 0x108)
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + 0x108)
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + 0x108)
   END
 END
BUT_ONLY_IF_IT_CHANGES

// Eler Had: thief with kit: berserker (has enrage, but none memorized and not scripted to cast)
COPY_EXISTING ~gromg09.cre~  ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x02)
   INSERT_BYTES "fxo" (0x108 * 0x02)
     FOR ("i" = 0x00; "i" < (0x108 * 0x02); "i" += 0x108) BEGIN
       WRITE_LONG  ("fxo" + "i" + 0x08) 0xe9 // opcode: weaponprof
       WRITE_LONG  ("fxo" + "i" + 0x1c) 0x09 // perm. after death
       WRITE_SHORT ("fxo" + "i" + 0x24) 0x64 // minimum probability
       WRITE_LONG  ("fxo" + "i" + 0xc4) 0x01 // secondary type
     END
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x14) 0x01 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x18) 0x60 // dagger prof
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x14) 0x01 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x18) 0x71 // single weapon prof
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + (0x108 * 0x02))
   END
 END
BUT_ONLY_IF_IT_CHANGES

// the rest of Gromnir's berserkers also forgot their enrages in their other pair of pants
COPY_EXISTING ~gromg01.cre~ ~override~ // Il-Khan Soldier
             ~gromg04.cre~ ~override~ // Il-Khan Soldier
             ~gromg06.cre~ ~override~ // Il-Khan Soldier
             ~gromg07.cre~ ~override~ // Il-Khan Soldier
             ~gromg09.cre~ ~override~ // Eler Had
             ~gromg10.cre~ ~override~ // Berena Elkan
             ~gromg12.cre~ ~override~ // Il-Khan Soldier
             ~gromg14.cre~ ~override~ // Il-Khan Soldier
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   READ_LONG  0x2a0 "kso"
   PATCH_IF ("kso" = 0x00) THEN BEGIN
     SET "kso" = 0x2d4
     WRITE_LONG  0x2a0 "kso"
   END
   READ_LONG  0x2a4 "ksc"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2ac "smc"
   READ_LONG  0x2b0 "mso"
   PATCH_IF ("mso" = 0x00) THEN BEGIN
     SET "mso" = 0x2d4
     WRITE_LONG  0x2b0 "mso"
   END
   READ_LONG  0x2b4 "msc"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   INSERT_BYTES "kso" 0x0c
     WRITE_ASCIIT ("kso" + 0x00) ~spcl321~
     WRITE_SHORT  ("kso" + 0x08) 0x00 // level
     WRITE_SHORT  ("kso" + 0x0a) 0x02 // type: innate
   WRITE_LONG   0x2a4 ("ksc" + 0x01)
   PATCH_IF ("smo" >= "kso") THEN BEGIN
     SET "smo" = ("smo" + 0x0c)
     WRITE_LONG 0x2a8 "smo"
   END
   PATCH_IF ("mso" >= "kso") THEN BEGIN
     SET "mso" = ("mso" + 0x0c)
     WRITE_LONG 0x2b0 "mso"
   END
   PATCH_IF ("iso" >= "kso") THEN BEGIN
     SET "iso" = ("iso" + 0x0c)
     WRITE_LONG 0x2b8 "iso"
   END
   PATCH_IF ("ilo" >= "kso") THEN BEGIN
     SET "ilo" = ("ilo" + 0x0c)
     WRITE_LONG 0x2bc "ilo"
   END
   PATCH_IF ("fxo" >= "kso") THEN BEGIN
     SET "fxo" = ("fxo" + 0x0c)
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_SHORT     ("smo" + 0x102) "nmu" // number memorizable
   WRITE_SHORT    ("smo" + 0x102) "nmu" + 0x01
   READ_SHORT     ("smo" + 0x104) "nmm" // number memorizable
   WRITE_SHORT    ("smo" + 0x104) "nmm" + 0x01
   READ_LONG      ("smo" + 0x10c) "nmc" // count
   WRITE_LONG     ("smo" + 0x10c) "nmc" + 0x01
   INSERT_BYTES "mso" (0x0c)
     WRITE_ASCIIT ("mso" + 0x00) ~spcl321~
     WRITE_LONG   ("mso" + 0x08) 0x01
   WRITE_LONG   0x2b4 ("msc" + 0x01)
   PATCH_IF ("kso" >= "mso") THEN BEGIN
     SET "kso" = ("kso" + 0x0c)
     WRITE_LONG 0x2a0 "kso"
   END
   PATCH_IF ("smo" >= "mso") THEN BEGIN
     SET "smo" = ("smo" + 0x0c)
     WRITE_LONG 0x2a8 "smo"
   END
   PATCH_IF ("iso" >= "mso") THEN BEGIN
     SET "iso" = ("iso" + 0x0c)
     WRITE_LONG 0x2b8 "iso"
   END
   PATCH_IF ("ilo" >= "mso") THEN BEGIN
     SET "ilo" = ("ilo" + 0x0c)
     WRITE_LONG 0x2bc "ilo"
   END
   PATCH_IF ("fxo" >= "mso") THEN BEGIN
     SET "fxo" = ("fxo" + 0x0c)
     WRITE_LONG 0x2c4 "fxo"
   END
 END
BUT_ONLY_IF_IT_CHANGES

// Sendai (statue): fighter/thief multi with kit: kensai (has kai but not scripted to use)
COPY_EXISTING ~sendai6.cre~  ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x01)
   INSERT_BYTES "fxo" 0x108
     WRITE_LONG  ("fxo" + 0x08) 0xe9 // opcode: weaponprof
     WRITE_LONG  ("fxo" + 0x14) 0x03 // stars
     WRITE_LONG  ("fxo" + 0x18) 0x60 // dagger prof for her offhand
     WRITE_LONG  ("fxo" + 0x1c) 0x09 // perm. after death
     WRITE_SHORT ("fxo" + 0x24) 0x64 // minimum probability
     WRITE_LONG  ("fxo" + 0xc4) 0x01 // secondary type
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + 0x108)
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + 0x108)
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + 0x108)
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + 0x108)
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + 0x108)
   END
 END
BUT_ONLY_IF_IT_CHANGES

// adding support for kai for sendai6.cre
EXTEND_BOTTOM ~sendai4.bcs~ ~npcprofs/baf/kensikia.baf~

// Artemis Entreri dualled from fighter into a single class thief
COPY_EXISTING ~artemis.cre~  ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   WRITE_BYTE 0x0234 0x0f // level 1st class
   WRITE_BYTE 0x0235 0x0b // level 2nd class
   WRITE_BYTE 0x0273 0x09 // fighter->thief
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x02)
   INSERT_BYTES "fxo" (0x108 * 0x02)
     FOR ("i" = 0x00; "i" < (0x108 * 0x02); "i" += 0x108) BEGIN
       WRITE_LONG  ("fxo" + "i" + 0x08) 0xe9 // opcode: weaponprof
       WRITE_LONG  ("fxo" + "i" + 0x1c) 0x09 // perm. after death
       WRITE_SHORT ("fxo" + "i" + 0x24) 0x64 // minimum probability
       WRITE_LONG  ("fxo" + "i" + 0xc4) 0x01 // secondary type
     END
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x14) 0x05 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x18) 0x60 // dagger prof
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x14) 0x03 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x18) 0x5b // short sword prof
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + (0x108 * 0x02))
   END
   ADD_CRE_ITEM ~dagg20~ #0 #0 #0 ~UNDROPPABLE~ ~SHIELD~
 END
BUT_ONLY_IF_IT_CHANGES

// Drizzt and his band of munchkins
// be a ranger!
COPY_EXISTING ~c6drizz.cre~   ~override~
             ~c6drizz2.cre~  ~override~
             ~c6drizz3.cre~  ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   WRITE_BYTE 0x273 0x00c
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END  
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x03)
   INSERT_BYTES "fxo" (0x108 * 0x03)
     FOR ("i" = 0x00; "i" < (0x108 * 0x03); "i" += 0x108) BEGIN
       WRITE_LONG  ("fxo" + "i" + 0x08) 0xe9 // opcode: weaponprof
       WRITE_LONG  ("fxo" + "i" + 0x1c) 0x09 // perm. after death
       WRITE_SHORT ("fxo" + "i" + 0x24) 0x64 // minimum probability
       WRITE_LONG  ("fxo" + "i" + 0xc4) 0x01 // secondary type
     END
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x14) 0x05 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x18) 0x5f // scimitar prof
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x14) 0x03 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x18) 0x72 // two-weapon prof
     WRITE_LONG   ("fxo" + (0x108 * 0x02) + 0x08) 0xf8 // opcode: give melee effect
     WRITE_ASCII  ("fxo" + (0x108 * 0x02) + 0x28) ~ih8drizt~
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + (0x108 * 0x03))
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + (0x108 * 0x03))
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + (0x108 * 0x03))
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + (0x108 * 0x03))
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + (0x108 * 0x03))
   END
   REPLACE_CRE_ITEM ~sw1h15~    #0 #0 #0 ~IDENTIFIED~              ~WEAPON1~ ~EQUIP~
   ADD_CRE_ITEM     ~sw1h16~    #0 #0 #0 ~IDENTIFIED~              ~SHIELD~
   REPLACE_CRE_ITEM ~helmnoan~  #0 #0 #0 ~UNSTEALABLE&UNDROPPABLE~ ~HELMET~
   REPLACE_CRE_ITEM ~boot06~    #0 #0 #0 ~UNSTEALABLE&UNDROPPABLE~ ~GLOVES~
 END
BUT_ONLY_IF_IT_CHANGES

// new .eff to simulate drizzt's "skull" weapon
COPY_EXISTING ~magicdam.eff~ ~override/ih8drizt.eff~
 PATCH_IF (%SOURCE_SIZE% = 0x110) THEN BEGIN
   WRITE_ASCII  0x00 ~EFF V2.0~
   WRITE_ASCIIT 0x08 ~~
   WRITE_LONG   0x10 0x00c // opcode: damage
   WRITE_LONG   0x14 0x002 // preset target
   WRITE_LONG   0x18 0x000 // power
   WRITE_LONG   0x1c 0x01e // fixed damage
   WRITE_SHORT  0x20 0x000 // mode: normal
   WRITE_SHORT  0x22 0x100 // slashing
   WRITE_LONG   0x24 0x001 // instant/permanent
   WRITE_LONG   0x28 0x000
   WRITE_SHORT  0x2c 0x064 // minimum probability
   WRITE_SHORT  0x2e 0x000
   WRITE_ASCIIT 0x30 ~~
   WRITE_LONG   0x38 0x000 // dice thrown
   WRITE_LONG   0x3c 0x000 // dice sides
   WRITE_LONG   0x40 0x002 // save vs death/poison
   WRITE_LONG   0x44 0x004 // save bonus
   WRITE_LONG   0x48 0x000
   WRITE_LONG   0x4c 0x000
   WRITE_LONG   0x50 0x000
   WRITE_LONG   0x54 0x000
   WRITE_LONG   0x58 0x000
   WRITE_LONG   0x5c 0x000
   WRITE_LONG   0x60 0x000
   WRITE_LONG   0x64 0x000
   WRITE_LONG   0x68 0x000
   WRITE_LONG   0x6c 0x000
   WRITE_LONG   0x70 0x000
   WRITE_LONG   0x74 0x000
   WRITE_ASCIIT 0x78 ~~
   WRITE_LONG   0x80 0xffffffff
   WRITE_LONG   0x84 0xffffffff
   WRITE_LONG   0x88 0xffffffff
   WRITE_LONG   0x8c 0xffffffff
   WRITE_LONG   0x90 0x000
   WRITE_ASCIIT 0x94 ~None~
   WRITE_LONG   0x9c 0x000
   WRITE_LONG   0xa0 0x000
   WRITE_LONG   0xa4 0xffffffff
   WRITE_ASCIIT 0xa8 ~~ (0x20)
   WRITE_LONG   0xc8 0x000
   WRITE_LONG   0xcc 0x000 // secondary type
   WRITE_ASCIIT 0xd0 ~~ (0x40)
 END
BUT_ONLY_IF_IT_CHANGES

// Wulfgar don't know warhammers real good
COPY_EXISTING ~c6wulf.cre~    ~override~
             ~c6wulf2.cre~   ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x01)
   INSERT_BYTES "fxo" (0x108)
     WRITE_LONG  ("fxo" + 0x08) 0xe9 // opcode: weaponprof
     WRITE_LONG  ("fxo" + 0x14) 0x05 // stars
     WRITE_LONG  ("fxo" + 0x18) 0x61 // warhammer prof
     WRITE_LONG  ("fxo" + 0x1c) 0x09 // perm. after death
     WRITE_SHORT ("fxo" + 0x24) 0x64 // minimum probability
     WRITE_LONG  ("fxo" + 0xc4) 0x01 // secondary type
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + 0x108)
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + 0x108)
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + 0x108)
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + 0x108)
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + 0x108)
   END
 END
BUT_ONLY_IF_IT_CHANGES

// it's a magic hammer-tooth-thingy, no?
COPY_EXISTING ~aegis.itm~  ~override~
             ~aegis2.itm~ ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x71) THEN BEGIN
   WRITE_LONG  0x08 0x18c9 // unidentified name
   WRITE_BYTE  0x31 0x61   // warhammer proficiency
   WRITE_LONG  0x60 0x03   // enchantment level
 END
BUT_ONLY_IF_IT_CHANGES

// Catti is neither a man nor unproficient with her dupe weapons
COPY_EXISTING ~c6catti.cre~   ~override~
             ~c6catti2.cre~  ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   WRITE_BYTE 0x247 0x02
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x02)
   INSERT_BYTES "fxo" (0x108 * 0x02)
     FOR ("i" = 0x00; "i" < (0x108 * 0x02); "i" += 0x108) BEGIN
       WRITE_LONG  ("fxo" + "i" + 0x08) 0xe9 // opcode: weaponprof
       WRITE_LONG  ("fxo" + "i" + 0x1c) 0x09 // perm. after death
       WRITE_SHORT ("fxo" + "i" + 0x24) 0x64 // minimum probability
       WRITE_LONG  ("fxo" + "i" + 0xc4) 0x01 // secondary type
     END
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x14) 0x05 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x00) + 0x18) 0x5a // longsword prof
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x14) 0x05 // stars
     WRITE_LONG   ("fxo" + (0x108 * 0x01) + 0x18) 0x69 // shortbow prof
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + (0x108 * 0x02))
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + (0x108 * 0x02))
   END
 END
BUT_ONLY_IF_IT_CHANGES

// Bruenor don't know axes real good niether(sic)
COPY_EXISTING ~c6bruen.cre~   ~override~
             ~c6bruen2.cre~  ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x01)
   INSERT_BYTES "fxo" (0x108)
     WRITE_LONG  ("fxo" + 0x08) 0xe9 // opcode: weaponprof
     WRITE_LONG  ("fxo" + 0x14) 0x05 // stars
     WRITE_LONG  ("fxo" + 0x18) 0x5c // axe prof
     WRITE_LONG  ("fxo" + 0x1c) 0x09 // perm. after death
     WRITE_SHORT ("fxo" + 0x24) 0x64 // minimum probability
     WRITE_LONG  ("fxo" + 0xc4) 0x01 // secondary type
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + 0x108)
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + 0x108)
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + 0x108)
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + 0x108)
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + 0x108)
   END
 END
BUT_ONLY_IF_IT_CHANGES

// but that doesn't excuse the description mismatch
COPY_EXISTING ~bruenaxe.itm~ ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x71) THEN BEGIN
   WRITE_BYTE 0x31 0x5c // axe proficiency
   READ_LONG  0x64 "ho"
   READ_SHORT 0x68 "hc"
   READ_LONG  0x6a "eo"
   FOR ("i" = 0x00; "i" < "hc"; "i" += 0x01) BEGIN
     READ_BYTE     ("hc" + (0x38 * "i") + 0x00) "at"
     PATCH_IF ("at" = 0x01) THEN BEGIN
       WRITE_SHORT ("hc" + (0x38 * "i") + 0x18) 0x01 // dice thrown
     END
   END
 END
BUT_ONLY_IF_IT_CHANGES

// like any thief, Regis ought to have grandmastery in stuff
COPY_EXISTING ~c6regis.cre~   ~override~
             ~c6regis2.cre~  ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   READ_LONG  0x2a0 "kso"
   READ_LONG  0x2a4 "ksc"
   READ_LONG  0x2a8 "smo"
   READ_LONG  0x2ac "smc"
   READ_LONG  0x2b0 "mso"
   READ_LONG  0x2b4 "msc"
   READ_LONG  0x2b8 "iso"
   READ_LONG  0x2bc "ilo"
   READ_LONG  0x2c0 "ilc"
   READ_LONG  0x2c4 "fxo"
   PATCH_IF ("fxo" = 0x00) THEN BEGIN
     SET "fxo" = 0x2d4
     WRITE_LONG 0x2c4 "fxo"
   END
   READ_LONG  0x2c8 "fxc"
   WRITE_LONG 0x2c8 ("fxc" + 0x01)
   INSERT_BYTES "fxo" (0x108 * 0x01)
     WRITE_LONG  ("fxo" + 0x08) 0xe9 // opcode: weaponprof
     WRITE_LONG  ("fxo" + 0x14) 0x05 // stars
     WRITE_LONG  ("fxo" + 0x18) 0x65 // mace prof
     WRITE_LONG  ("fxo" + 0x1c) 0x09 // perm. after death
     WRITE_SHORT ("fxo" + 0x24) 0x64 // minimum probability
     WRITE_LONG  ("fxo" + 0xc4) 0x01 // secondary type
   PATCH_IF (NOT "kso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a0 ("kso" + 0x108)
   END
   PATCH_IF (NOT "smo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2a8 ("smo" + 0x108)
   END
   PATCH_IF (NOT "mso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b0 ("mso" + 0x108)
   END
   PATCH_IF (NOT "iso" < "fxo") THEN BEGIN
     WRITE_LONG 0x2b8 ("iso" + 0x108)
   END
   PATCH_IF (NOT "ilo" < "fxo") THEN BEGIN
     WRITE_LONG 0x2bc ("ilo" + 0x108)
   END
 END
BUT_ONLY_IF_IT_CHANGES

Link to comment

And the beast itself - or as much of it as fits in a single post :)

///////////////////////////////////////////////////////////////////////
// reading and sorting necessary information from creatures so that  //
// they can have proficiencies added in a minimally-stupid way.      //
///////////////////////////////////////////////////////////////////////

INCLUDE ~npcprofs/lib/macro_archer_profs.tph~
INCLUDE ~npcprofs/lib/macro_barbarian_profs.tph~
INCLUDE ~npcprofs/lib/macro_bard_profs.tph~
INCLUDE ~npcprofs/lib/macro_beastmaster_profs.tph~
INCLUDE ~npcprofs/lib/macro_blade_profs.tph~
INCLUDE ~npcprofs/lib/macro_berserker_profs.tph~
INCLUDE ~npcprofs/lib/macro_berserker_cleric_profs.tph~
INCLUDE ~npcprofs/lib/macro_berserker_druid_profs.tph~
INCLUDE ~npcprofs/lib/macro_cavalier_profs.tph~
INCLUDE ~npcprofs/lib/macro_cleric_profs.tph~
INCLUDE ~npcprofs/lib/macro_cleric_archer_profs.tph~
INCLUDE ~npcprofs/lib/macro_cleric_beastmaster_profs.tph~
INCLUDE ~npcprofs/lib/macro_cleric_fighter_profs.tph~
INCLUDE ~npcprofs/lib/macro_cleric_mage_profs.tph~
INCLUDE ~npcprofs/lib/macro_cleric_ranger_profs.tph~
INCLUDE ~npcprofs/lib/macro_cleric_swashbuckler_profs.tph~
INCLUDE ~npcprofs/lib/macro_cleric_thief_profs.tph~
INCLUDE ~npcprofs/lib/macro_druid_profs.tph~
INCLUDE ~npcprofs/lib/macro_druid_fighter_profs.tph~
INCLUDE ~npcprofs/lib/macro_fighter_profs.tph~
INCLUDE ~npcprofs/lib/macro_fighter_cleric_profs.tph~
INCLUDE ~npcprofs/lib/macro_fighter_druid_profs.tph~
INCLUDE ~npcprofs/lib/macro_fighter_mage_profs.tph~
INCLUDE ~npcprofs/lib/macro_fighter_thief_profs.tph~
INCLUDE ~npcprofs/lib/macro_kensai_profs.tph~
INCLUDE ~npcprofs/lib/macro_kensai_cleric_profs.tph~
INCLUDE ~npcprofs/lib/macro_kensai_druid_profs.tph~
INCLUDE ~npcprofs/lib/macro_mage_profs.tph~
INCLUDE ~npcprofs/lib/macro_mage_cleric_profs.tph~
INCLUDE ~npcprofs/lib/macro_monk_profs.tph~
INCLUDE ~npcprofs/lib/macro_paladin_profs.tph~
INCLUDE ~npcprofs/lib/macro_ranger_profs.tph~
INCLUDE ~npcprofs/lib/macro_swashbuckler_profs.tph~
INCLUDE ~npcprofs/lib/macro_thief_profs.tph~
INCLUDE ~npcprofs/lib/macro_thief_fighter_profs.tph~
INCLUDE ~npcprofs/lib/macro_reindex_profs.tph~

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN
   PATCH_IF (("%SOURCE_RES%" STRING_COMPARE_CASE "modcreat")  AND //
             ("%SOURCE_RES%" STRING_COMPARE_CASE "modcreat")  AND // advertise YOUR MOD HERE! A ten spot gets you a permanent mention in the comments of this tp2
             ("%SOURCE_RES%" STRING_COMPARE_CASE "modcreat")) THEN BEGIN
     // read the basics from the creature
     READ_LONG    0x0010 "flags"
     READ_BYTE    0x006e "default_none"
     READ_BYTE    0x0234 "1st_class_level"
     READ_BYTE    0x0235 "2nd_class_level"
     READ_LONG    0x0244 "kit"
     READ_BYTE    0x0273 "class"
     READ_LONG    0x02a0 "known_spells_offset"
     READ_LONG    0x02a8 "memorized_table_offset"
     READ_LONG    0x02b0 "memorized_spells_offset"
     READ_LONG    0x02b8 "item_slot_offset"
     READ_LONG    0x02bc "item_table_offset"
     READ_LONG    0x02c0 "item_table_count"
     READ_LONG    0x02c4 "effects_offset"
     PATCH_IF ("effects_offset" = 0x00) THEN BEGIN
       SET "effects_offset" = %SOURCE_SIZE%
       WRITE_LONG 0x02c4 "effects_offset"
     END
     READ_LONG    0x02c8 "effects_count"
     // define a fat lot of variables NO_IF_EVAL_BUG_PLZ_THX_BIGG
     SET "dualled_from_fighter" = 0x00
     SET "dualled_from_mage" = 0x00
     SET "dualled_from_cleric" = 0x00
     SET "dualled_from_thief" = 0x00
     SET "dualled_from_druid" = 0x00
     SET "dualled_from_ranger" = 0x00
     SET "bastard_swords" = 0x00
     SET "needs_bastard_swords" = 0x00
     SET "long_swords" = 0x00
     SET "needs_long_swords" = 0x00
     SET "short_swords" = 0x00
     SET "needs_short_swords" = 0x00
     SET "axes" = 0x00
     SET "needs_axes" = 0x00
     SET "two_handed_swords" = 0x00
     SET "needs_two_handed_swords" = 0x00
     SET "katanas" = 0x00
     SET "needs_katanas" = 0x00
     SET "scimitars_wakizashis_ninjatos" = 0x00
     SET "needs_scimitars_wakizashis_ninjatos" = 0x00
     SET "daggers" = 0x00
     SET "needs_daggers" = 0x00
     SET "war_hammers" = 0x00
     SET "needs_war_hammers" = 0x00
     SET "spears" = 0x00
     SET "needs_spears" = 0x00
     SET "halberds" = 0x00
     SET "needs_halberds" = 0x00
     SET "flails_morningstars" = 0x00
     SET "needs_flails_morningstars" = 0x00
     SET "maces" = 0x00
     SET "needs_maces" = 0x00
     SET "quarterstaves" = 0x00
     SET "needs_quarterstaves" = 0x00
     SET "crossbows" = 0x00
     SET "needs_crossbows" = 0x00
     SET "long_bows" = 0x00
     SET "needs_long_bows" = 0x00
     SET "short_bows" = 0x00
     SET "needs_short_bows" = 0x00
     SET "darts" = 0x00
     SET "needs_darts" = 0x00
     SET "slings" = 0x00
     SET "needs_slings" = 0x00
     SET "martial_arts" = 0x00
     SET "needs_martial_arts" = 0x00
     SET "two_handed_weapons" = 0x00
     SET "needs_two_handed_weapons" = 0x00
     SET "sword_and_shield" = 0x00
     SET "needs_sword_and_shield" = 0x00
     SET "single_weapons" = 0x00
     SET "needs_single_weapons" = 0x00
     SET "two_weapons" = 0x00
     SET "needs_two_weapons" = 0x00
     SET "clubs" = 0x00
     SET "needs_clubs" = 0x00
     SET "has_shield" = 0x00
     SET "has_twohander" = 0x00
     SET "due" = 0x00
     SET "fighter_due" = 0x00
     SET "mage_due" = 0x00
     SET "cleric_due" = 0x00
     SET "thief_due" = 0x00
     SET "bard_due" = 0x00
     SET "paladin_due" = 0x00
     SET "druid_due" = 0x00
     SET "ranger_due" = 0x00
     SET "monk_due" = 0x00
     SET "dual_wrapup_due" = 0x00
     SET "random_num" = 0x00
     SET "current_total_profs" = 0x00
     SET "added_effects" = 0x00
     // check for dual-classing
     PATCH_IF ("flags" != 0x00) THEN BEGIN
       PATCH_IF          (("flags" BOR 0xfffffff7) = 0xffffffff) THEN BEGIN
         SET "dualled_from_fighter" = 0x01
       END ELSE PATCH_IF (("flags" BOR 0xffffffef) = 0xffffffff) THEN BEGIN
         SET "dualled_from_mage" = 0x01
       END ELSE PATCH_IF (("flags" BOR 0xffffffdf) = 0xffffffff) THEN BEGIN
         SET "dualled_from_cleric" = 0x01
       END ELSE PATCH_IF (("flags" BOR 0xffffffbf) = 0xffffffff) THEN BEGIN
         SET "dualled_from_thief" = 0x01
       END ELSE PATCH_IF (("flags" BOR 0xffffff7f) = 0xffffffff) THEN BEGIN
         SET "dualled_from_druid" = 0x01
       END ELSE PATCH_IF (("flags" BOR 0xfffffeff) = 0xffffffff) THEN BEGIN
         SET "dualled_from_ranger" = 0x01
       END
     END
     // check for extant proficiencies and note them
     PATCH_IF ("effects_count" > 0x00) THEN BEGIN
       FOR ("i" = 0x000; "i" < ("effects_count" * 0x108); "i" += 0x108) BEGIN
         READ_LONG   ("effects_offset" + "i" + 0x08) "opcode"
         PATCH_IF    ("opcode" = 0xe9) THEN BEGIN
           READ_LONG ("effects_offset" + "i" + 0x14) "weapon_prof_stars"
           READ_LONG ("effects_offset" + "i" + 0x18) "weapon_prof_type"
           PATCH_IF          ("weapon_prof_type" = 0x59) THEN BEGIN
             SET "bastard_swords" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x5a) THEN BEGIN
             SET "long_swords" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x5b) THEN BEGIN
             SET "short_swords" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x5c) THEN BEGIN
             SET "axes" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x5d) THEN BEGIN
             SET "two_handed_swords" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x5e) THEN BEGIN
             SET "katanas" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x5f) THEN BEGIN
             SET "scimitars_wakizashis_ninjatos" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x60) THEN BEGIN
             SET "daggers" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x61) THEN BEGIN
             SET "war_hammers" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x62) THEN BEGIN
             SET "spears" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x63) THEN BEGIN
             SET "halberds" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x64) THEN BEGIN
             SET "flails_morningstars" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x65) THEN BEGIN
             SET "maces" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x66) THEN BEGIN
             SET "quarterstaves" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x67) THEN BEGIN
             SET "crossbows" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x68) THEN BEGIN
             SET "long_bows" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x69) THEN BEGIN
             SET "short_bows" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x6a) THEN BEGIN
             SET "darts" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x6b) THEN BEGIN
             SET "slings" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x6e) THEN BEGIN
             SET "martial_arts" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x6f) THEN BEGIN
             SET "two_handed_weapons" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x70) THEN BEGIN
             SET "sword_and_shield" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x71) THEN BEGIN
             SET "single_weapons" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x72) THEN BEGIN
             SET "two_weapons" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END ELSE PATCH_IF ("weapon_prof_type" = 0x73) THEN BEGIN
             SET "clubs" = "weapon_prof_stars"
             SET "current_total_profs" += "weapon_prof_stars"
           END
         END
       END
     END
     // check which, if any weapons equipped and whether or not the creature knows how to use them
     PATCH_IF ("item_table_count" > 0x00) THEN BEGIN
       FOR ("j" = 0x04; "j" < 0x56; "j" += 0x02)  BEGIN
         READ_SHORT ("item_slot_offset" + "j") "weapon_slot_index"
         PATCH_IF (("weapon_slot_index" != 0xffff) AND ("j" = 0x04)) THEN BEGIN
           READ_ASCII ("item_table_offset" + (0x14 * "weapon_slot_index") + 0x00) "weapon" ELSE 0
           PATCH_IF ("%weapon%" STR_CMP "        ") THEN BEGIN
             INNER_PATCH_FILE ~%weapon%.itm~ BEGIN
               READ_SHORT  0x1c "weapon_inventory_type" ELSE 0
               READ_BYTE   0x31 "equipped_prof"         ELSE 0
             END
             PATCH_IF (("bastard_swords" = 0x00) AND ("equipped_prof" = 0x59)) THEN BEGIN
               SET "needs_bastard_swords" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("long_swords" = 0x00) AND ("equipped_prof" = 0x5a)) THEN BEGIN
               SET "needs_long_swords" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("short_swords" = 0x00) AND ("equipped_prof" = 0x5b)) THEN BEGIN
               SET "needs_short_swords" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("axes" = 0x00) AND ("equipped_prof" = 0x5c)) THEN BEGIN
               SET "needs_axes" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("katanas" = 0x00) AND ("equipped_prof" = 0x5e)) THEN BEGIN
               SET "needs_katanas" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("scimitars_wakizashis_ninjatos" = 0x00) AND ("equipped_prof" = 0x5f)) THEN BEGIN
               SET "needs_scimitars_wakizashis_ninjatos" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("daggers" = 0x00) AND ("equipped_prof" = 0x60)) THEN BEGIN
               SET "needs_daggers" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("war_hammers" = 0x00) AND ("equipped_prof" = 0x61)) THEN BEGIN
               SET "needs_war_hammers" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("spears" = 0x00) AND ("equipped_prof" = 0x62)) THEN BEGIN
               SET "needs_spears" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("flails_morningstars" = 0x00) AND ("equipped_prof" = 0x64)) THEN BEGIN
               SET "needs_flails_morningstars" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("maces" = 0x00) AND ("equipped_prof" = 0x65)) THEN BEGIN
               SET "needs_maces" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("quarterstaves" = 0x00) AND ("equipped_prof" = 0x66)) THEN BEGIN
               SET "needs_quarterstaves" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("martial_arts" = 0x00) AND ("equipped_prof" = 0x6e)) THEN BEGIN
               SET "needs_martial_arts" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("clubs" = 0x00) AND ("equipped_prof" = 0x73)) THEN BEGIN
               SET "needs_clubs" = 0x01
               SET "needs_two_weapons" = 0x01
             END ELSE PATCH_IF (("equipped_prof" = 0x00) AND ("weapon_inventory_type" = 0x0c))THEN BEGIN
               SET "needs_sword_and_shield" = 0x01
               SET "has_shield" = 0x01
             END
           END
         END
         PATCH_IF (("weapon_slot_index" = 0xffff) AND ("j" = 0x04)) THEN BEGIN
           SET "needs_single_weapons" = 0x01
         END
         PATCH_IF ((("j" = 0x12) OR ("j" = 0x14) OR ("j" = 0x16) OR ("j" = 0x18)) AND ("weapon_slot_index" != 0xffff)) THEN BEGIN
           READ_ASCII ("item_table_offset" + (0x14 * "weapon_slot_index") + 0x00) "weapon" ELSE 0
           PATCH_IF ("%weapon%" STR_CMP "        ") THEN BEGIN
             INNER_PATCH_FILE ~%weapon%.itm~ BEGIN
               READ_BYTE   0x31 "equipped_prof" ELSE 0
             END
             PATCH_IF (("bastard_swords" = 0x00) AND ("equipped_prof" = 0x59)) THEN BEGIN
               SET "needs_bastard_swords" = 0x01
             END ELSE PATCH_IF (("long_swords" = 0x00) AND ("equipped_prof" = 0x5a)) THEN BEGIN
               SET "needs_long_swords" = 0x01
             END ELSE PATCH_IF (("short_swords" = 0x00) AND ("equipped_prof" = 0x5b)) THEN BEGIN
               SET "needs_short_swords" = 0x01
             END ELSE PATCH_IF (("axes" = 0x00) AND ("equipped_prof" = 0x5c)) THEN BEGIN
               SET "needs_axes" = 0x01
             END ELSE PATCH_IF (("two_handed_swords" = 0x00) AND ("equipped_prof" = 0x5d)) THEN BEGIN
               SET "needs_two_handed_swords" = 0x01
               SET "needs_two_handed_weapons" = 0x01
             END ELSE PATCH_IF (("katanas" = 0x00) AND ("equipped_prof" = 0x5e)) THEN BEGIN
               SET "needs_katanas" = 0x01
             END ELSE PATCH_IF (("scimitars_wakizashis_ninjatos" = 0x00) AND ("equipped_prof" = 0x5f)) THEN BEGIN
               SET "needs_scimitars_wakizashis_ninjatos" = 0x01
             END ELSE PATCH_IF (("daggers" = 0x00) AND ("equipped_prof" = 0x60)) THEN BEGIN
               SET "needs_daggers" = 0x01
             END ELSE PATCH_IF (("war_hammers" = 0x00) AND ("equipped_prof" = 0x61)) THEN BEGIN
               SET "needs_war_hammers" = 0x01
             END ELSE PATCH_IF (("spears" = 0x00) AND ("equipped_prof" = 0x62)) THEN BEGIN
               SET "needs_spears" = 0x01
               SET "needs_two_handed_weapons" = 0x01
             END ELSE PATCH_IF (("halberds" = 0x00) AND ("equipped_prof" = 0x63)) THEN BEGIN
               SET "needs_halberds" = 0x01
               SET "needs_two_handed_weapons" = 0x01
             END ELSE PATCH_IF (("flails_morningstars" = 0x00) AND ("equipped_prof" = 0x64)) THEN BEGIN
               SET "needs_flails_morningstars" = 0x01
             END ELSE PATCH_IF (("maces" = 0x00) AND ("equipped_prof" = 0x65)) THEN BEGIN
               SET "needs_maces" = 0x01
             END ELSE PATCH_IF (("quarterstaves" = 0x00) AND ("equipped_prof" = 0x66)) THEN BEGIN
               SET "needs_quarterstaves" = 0x01
               SET "needs_two_handed_weapons" = 0x01
             END ELSE PATCH_IF (("crossbows" = 0x00) AND ("equipped_prof" = 0x67)) THEN BEGIN
               SET "needs_crossbows" = 0x01
             END ELSE PATCH_IF (("long_bows" = 0x00) AND ("equipped_prof" = 0x68)) THEN BEGIN
               SET "needs_long_bows" = 0x01
             END ELSE PATCH_IF (("short_bows" = 0x00) AND ("equipped_prof" = 0x69)) THEN BEGIN
               SET "needs_short_bows" = 0x01
             END ELSE PATCH_IF (("darts" = 0x00) AND ("equipped_prof" = 0x6a)) THEN BEGIN
               SET "needs_darts" = 0x01
             END ELSE PATCH_IF (("slings" = 0x00) AND ("equipped_prof" = 0x6b)) THEN BEGIN
               SET "needs_slings" = 0x01
             END ELSE PATCH_IF (("martial_arts" = 0x00) AND ("equipped_prof" = 0x6e)) THEN BEGIN
               SET "needs_martial_arts" = 0x01
             END ELSE PATCH_IF (("clubs" = 0x00) AND ("equipped_prof" = 0x73)) THEN BEGIN
               SET "needs_clubs" = 0x01
             END
           END
         END
         PATCH_IF ("j" = 0x04) THEN BEGIN
           SET "j" = 0x10
         END
         PATCH_IF ("j" = 0x18) THEN BEGIN
           SET "j" = 0x56
         END
       END
     END
     // calculate how many proficiencies a creature should have and compare to how many it does have
     //
     // single class mage and sorceror
     PATCH_IF (("class" = 0x01) OR ("class" = 0x13)) THEN BEGIN
       SET "due" = (((0x01 + ("1st_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("1st_class_level" / 0x06)))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         SET "mage_due" = ((((0x01 + ("1st_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("1st_class_level" / 0x06))) - "current_total_profs")
         // abjurer
         PATCH_IF          ("kit" = 0x00400000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // conjurer
         END ELSE PATCH_IF ("kit" = 0x00800000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // diviner
         END ELSE PATCH_IF ("kit" = 0x01000000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // enchanter
         END ELSE PATCH_IF ("kit" = 0x02000000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // illusionist
         END ELSE PATCH_IF ("kit" = 0x04000000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // invoker
         END ELSE PATCH_IF ("kit" = 0x08000000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // necromancer
         END ELSE PATCH_IF ("kit" = 0x10000000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // transmuter
         END ELSE PATCH_IF ("kit" = 0x20000000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // wild mage
         END ELSE PATCH_IF ("kit" = 0x80000000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // no kit
         END ELSE PATCH_IF ("kit" = 0x00000000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // generalist = free bonus no forbiddance
         END ELSE PATCH_IF ("kit" = 0x40000000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~mage_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // fighter
     PATCH_IF ("class" = 0x02) THEN BEGIN
       SET "due" = (0x04 + ("1st_class_level" / 0x03))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         SET "fighter_due" = (0x04 + ("1st_class_level" / 0x03))
         // berserker
         PATCH_IF          (("kit" = 0x40010000) OR ("kit" = 0x00010000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~berserker_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // wizard slayer
         END ELSE PATCH_IF (("kit" = 0x40020000) OR ("kit" = 0x00020000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~fighter_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // kensai
         END ELSE PATCH_IF (("kit" = 0x40030000) OR ("kit" = 0x00040000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~kensai_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // barbarian - not all will be caught thanks to stupid kit.ids
         END ELSE PATCH_IF ("kit" = 0x00004000) THEN BEGIN
           LAUNCH_PATCH_MACRO ~barbarian_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // trueclass fighter
         END ELSE PATCH_IF (("kit" = 0x40000000) OR ("kit" = 0x00000000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~fighter_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // cleric
     PATCH_IF ("class" = 0x03) THEN BEGIN
       SET "due" = (((0x02 + ("1st_class_level" / 0x04)) > 0x0a) ? 0x0a : (0x02 + ("1st_class_level" / 0x04)))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         SET "cleric_due" = ((((0x02 + ("1st_class_level" / 0x04)) > 0x0a) ? 0x0a : (0x02 + ("1st_class_level" / 0x04))) - "current_total_profs")
         // priest of Talos
         PATCH_IF          (("kit" = 0x40130000) OR ("kit" = 0x00000100)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~cleric_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // priest of Helm
         END ELSE PATCH_IF (("kit" = 0x40140000) OR ("kit" = 0x00000200)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~cleric_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // priest of Lathlander
         END ELSE PATCH_IF (("kit" = 0x40150000) OR ("kit" = 0x00000400)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~cleric_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // generic cleric
         END ELSE PATCH_IF (("kit" = 0x40000000) OR ("kit" = 0x00000000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~cleric_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // thief
     PATCH_IF ("class" = 0x04) THEN BEGIN
       SET "due" = (0x02 + ("1st_class_level" / 0x04))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         SET "thief_due" = ((0x02 + ("1st_class_level" / 0x04)) - "current_total_profs")
         // swashbuckler
         PATCH_IF          (("kit" = 0x400c0000) OR ("kit" = 0x00000010)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~swashbuckler_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // assassin
         END ELSE PATCH_IF (("kit" = 0x400a0000) OR ("kit" = 0x00000004)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~thief_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // bounty hunter
         END ELSE PATCH_IF (("kit" = 0x400b0000) OR ("kit" = 0x00000008)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~thief_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // trueclass thief
         END ELSE PATCH_IF (("kit" = 0x40000000) OR ("kit" = 0x00000000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~thief_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // bard
     PATCH_IF ("class" = 0x05) THEN BEGIN
       SET "due" = (0x02 + ("1st_class_level" / 0x04))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         SET "bard_due" = ((0x02 + ("1st_class_level" / 0x04)) - "current_total_profs")
         // blade
         PATCH_IF          (("kit" = 0x400d0000) OR ("kit" = 0x00000020)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~blade_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // jester
         END ELSE PATCH_IF (("kit" = 0x400e0000) OR ("kit" = 0x00000040)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~bard_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // skald
         END ELSE PATCH_IF (("kit" = 0x400f0000) OR ("kit" = 0x00000080)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~bard_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // trueclass bard
         END ELSE PATCH_IF (("kit" = 0x40000000) OR ("kit" = 0x00000000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~bard_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // paladin
     PATCH_IF ("class" = 0x06) THEN BEGIN
       SET "due" = (0x04 + ("1st_class_level" / 0x03))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         SET "paladin_due" = ((0x04 + ("1st_class_level" / 0x03)) - "current_total_profs")
         // cavalier
         PATCH_IF          (("kit" = 0x40040000) OR ("kit" = 0x00080000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~cavalier_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // inquisitor
         END ELSE PATCH_IF (("kit" = 0x40050000) OR ("kit" = 0x00100000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~paladin_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // undead hunter
         END ELSE PATCH_IF (("kit" = 0x40060000) OR ("kit" = 0x00200000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~paladin_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // trueclass paladin
         END ELSE PATCH_IF (("kit" = 0x40000000) OR ("kit" = 0x00000000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~paladin_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // fighter/mage multi
     PATCH_IF (("class" = 0x07) AND ("dualled_from_fighter" = 0x00) AND ("dualled_from_mage" = 0x00)) THEN BEGIN
       SET "due" = (0x04 + ("1st_class_level" / 0x03))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         SET "paladin_due" = ((0x04 + ("1st_class_level" / 0x03)) - "current_total_profs")
         // fighter/illusionist multi
         PATCH_IF           ("kit" = 0x04000000)                          THEN BEGIN
           LAUNCH_PATCH_MACRO ~paladin_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // fighter/mage multi
         END ELSE PATCH_IF (("kit" = 0x40000000) OR ("kit" = 0x00000000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~paladin_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // fighter->mage dual
     PATCH_IF (("class" = 0x07) AND ("dualled_from_fighter" = 0x01) AND ("dualled_from_mage" = 0x00)) THEN BEGIN
       SET "due" = ((0x04 + ("2nd_class_level" / 0x03)) + (0x01 + ("1st_class_level" / 0x06)))
       PATCH_IF ("current_total_profs" < "due")  THEN BEGIN
         PATCH_IF (NOT ("1st_class_level" > "2nd_class_level")) THEN BEGIN
           PATCH_IF (NOT ("current_total_profs" > (0x04 + ("2nd_class_level" / 0x03)))) THEN BEGIN
             SET "fighter_due"       = ((0x04 + ("2nd_class_level" / 0x03)) - "current_total_profs")
             SET "mage_due"          = (((0x01 + ("1st_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("1st_class_level" / 0x06)))
             SET "dual_wrapup_due"   = 0x00
           END ELSE BEGIN
             SET "fighter_due"       = 0x00
             SET "mage_due"          = ((((0x01 + ("1st_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("1st_class_level" / 0x06))) +  ((0x04 + ("2nd_class_level" / 0x03))) - "current_total_profs")
             SET "dual_wrapup_due"   = 0x00
           END
         END ELSE BEGIN
           PATCH_IF (NOT ("current_total_profs" > (0x04 + ("2nd_class_level" / 0x03)))) THEN BEGIN
             SET "fighter_due"       = ((0x04 + ("2nd_class_level" / 0x03)) - "current_total_profs")
             SET "mage_due"          = (((0x01 + ("2nd_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("2nd_class_level" / 0x06)))
             PATCH_IF (("1st_class_level" = 0x06) OR ("1st_class_level" = 0x0c) OR ("1st_class_level" = 0x12) OR ("1st_class_level" = 0x18) OR ("1st_class_level" = 0x1e) OR ("1st_class_level" = 0x24) OR ("1st_class_level" = 0x2a) OR ("1st_class_level" = 0x30)) THEN BEGIN
               SET "dual_wrapup_due" = ((("1st_class_level" - "2nd_class_level") / 0x06) + 0x01)
             END ELSE BEGIN
               SET "dual_wrapup_due" = (("1st_class_level" - "2nd_class_level") / 0x06)
             END
           END ELSE PATCH_IF (NOT ("current_total_profs" > ((0x04 + ("2nd_class_level" / 0x03))) + (0x01 + ("2nd_class_level" / 0x06)))) THEN BEGIN
             SET "fighter_due"       = 0x00
             SET "mage_due"          = ((((0x01 + ("1st_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("1st_class_level" / 0x06))) +  ((0x04 + ("2nd_class_level" / 0x03))) - "current_total_profs")
             PATCH_IF (("1st_class_level" = 0x06) OR ("1st_class_level" = 0x0c) OR ("1st_class_level" = 0x12) OR ("1st_class_level" = 0x18) OR ("1st_class_level" = 0x1e) OR ("1st_class_level" = 0x24) OR ("1st_class_level" = 0x2a) OR ("1st_class_level" = 0x30)) THEN BEGIN
               SET "dual_wrapup_due" = ((("1st_class_level" - "2nd_class_level") / 0x06) + 0x01)
             END ELSE BEGIN
               SET "dual_wrapup_due" = (("1st_class_level" - "2nd_class_level") / 0x06)
             END
           END ELSE BEGIN
             SET "fighter_due"       = 0x00
             SET "mage_due"          = 0x00
             SET "dual_wrapup_due"   = (((0x04 + ("2nd_class_level" / 0x03)) + (0x01 + ("1st_class_level" / 0x06))) - "current_total_profs")
           END
         END
         // berserker->mage
         PATCH_IF          (("kit" = 0x40010000) OR ("kit" = 0x00010000)) THEN BEGIN
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~berserker_profs~
           END
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~berserker_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // wizard slayer->mage
         END ELSE PATCH_IF (("kit" = 0x40020000) OR ("kit" = 0x00020000)) THEN BEGIN
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // kensai->mage
         END ELSE PATCH_IF (("kit" = 0x40030000) OR ("kit" = 0x00040000)) THEN BEGIN
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~kensai_profs~
           END
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~kensai_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // trueclass fighter->mage
         END ELSE PATCH_IF (("kit" = 0x40000000) OR ("kit" = 0x00000000)) THEN BEGIN
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // mage->fighter dual
     PATCH_IF (("class" = 0x07) AND ("dualled_from_fighter" = 0x00) AND ("dualled_from_mage" = 0x01)) THEN BEGIN
       SET "due" = ((0x04 + ("1st_class_level" / 0x03)) + (((0x01 + ("2nd_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("2nd_class_level" / 0x06))))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         PATCH_IF (NOT ("1st_class_level" > "2nd_class_level")) THEN BEGIN
           PATCH_IF (NOT ("current_total_profs" > ((0x01 + ("2nd_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("2nd_class_level" / 0x06)))) THEN BEGIN
             SET "mage_due"          = ((((0x01 + ("2nd_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("2nd_class_level" / 0x06))) - "current_total_profs")
             SET "fighter_due"       = (0x04 + ("1st_class_level" / 0x03))
             SET "dual_wrapup_due"   = 0x00
           END ELSE BEGIN
             SET "mage_due"          = 0x00
             SET "fighter_due"       = (((0x04 + ("1st_class_level" / 0x03)) + ((0x01 + ("2nd_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("2nd_class_level" / 0x06))) - "current_total_profs")
             SET "dual_wrapup_due"   = 0x00
           END
         END ELSE BEGIN
           PATCH_IF (NOT ("current_total_profs" > ((0x01 + ("2nd_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("2nd_class_level" / 0x06)))) THEN BEGIN
             SET "mage_due"          = ((((0x01 + ("2nd_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("2nd_class_level" / 0x06))) - "current_total_profs")
             SET "fighter_due"       = (0x04 + ("2nd_class_level" / 0x03))
             PATCH_IF (("1st_class_level" = 0x03) OR ("1st_class_level" = 0x06) OR ("1st_class_level" = 0x09) OR ("1st_class_level" = 0x0c) OR ("1st_class_level" = 0x0f) OR ("1st_class_level" = 0x12) OR ("1st_class_level" = 0x15) OR ("1st_class_level" = 0x18) OR ("1st_class_level" = 0x1b) OR ("1st_class_level" = 0x1e) OR ("1st_class_level" = 0x21) OR ("1st_class_level" = 0x24) OR  ("1st_class_level" = 0x27) OR ("1st_class_level" = 0x2a) OR ("1st_class_level" = 0x2d) OR  ("1st_class_level" = 0x30)) THEN BEGIN
               SET "dual_wrapup_due" = ((("1st_class_level" - "2nd_class_level") / 0x03) + 0x01)
             END ELSE BEGIN
               SET "dual_wrapup_due" = (("1st_class_level" - "2nd_class_level") / 0x03)
             END
           END ELSE PATCH_IF (NOT ("current_total_profs" > ((0x04 + ("1st_class_level" / 0x03))) + (0x01 + ("1st_class_level" / 0x06)))) THEN BEGIN
             SET "mage_due"          = 0x00
             SET "fighter_due"       = ((((0x01 + ("2nd_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("2nd_class_level" / 0x06))) +  ((0x04 + ("2nd_class_level" / 0x03))) - "current_total_profs")
             PATCH_IF (("1st_class_level" = 0x03) OR ("1st_class_level" = 0x06) OR ("1st_class_level" = 0x09) OR ("1st_class_level" = 0x0c) OR ("1st_class_level" = 0x0f) OR ("1st_class_level" = 0x12) OR ("1st_class_level" = 0x15) OR ("1st_class_level" = 0x18) OR ("1st_class_level" = 0x1b) OR ("1st_class_level" = 0x1e) OR ("1st_class_level" = 0x21) OR ("1st_class_level" = 0x24) OR  ("1st_class_level" = 0x27) OR ("1st_class_level" = 0x2a) OR ("1st_class_level" = 0x2d) OR  ("1st_class_level" = 0x30)) THEN BEGIN
               SET "dual_wrapup_due" = ((("1st_class_level" - "2nd_class_level") / 0x03) + 0x01)
             END ELSE BEGIN
               SET "dual_wrapup_due" = (("1st_class_level" - "2nd_class_level") / 0x03)
             END
           END ELSE BEGIN
             SET "mage_due"          = 0x00
             SET "fighter_due"       = 0x00
             SET "dual_wrapup_due"   = (((0x04 + ("1st_class_level" / 0x03)) + (((0x01 + ("2nd_class_level" / 0x06)) > 0x04) ? 0x04 : (0x01 + ("2nd_class_level" / 0x06)))) - "current_total_profs")
           END
         END
         // abjurer->fighter dual
         PATCH_IF          ("kit" = 0x00400000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // conjurer -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x00800000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // diviner -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x01000000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // enchanter -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x02000000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // illusionist -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x04000000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // invoker -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x08000000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // necromancer -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x10000000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // transmuter -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x20000000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // wild mage -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x80000000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // no kit mage -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x00000000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // generalist -> fighter dual
         END ELSE PATCH_IF ("kit" = 0x40000000) THEN BEGIN
           PATCH_IF ("mage_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~mage_profs~
           END
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // fighter/cleric multi
     PATCH_IF (("class" = 0x08) AND ("dualled_from_fighter" = 0x00) AND ("dualled_from_cleric" = 0x00)) THEN BEGIN
       SET "due" = (0x04 + ("1st_class_level" / 0x03))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         SET "fighter_due" = ((0x04 + ("1st_class_level" / 0x03)) - "current_total_profs")
         PATCH_IF (("kit" = 0x40000000) OR ("kit" = 0x00000000)) THEN BEGIN
           LAUNCH_PATCH_MACRO ~cleric_fighter_profs~
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END
     //
     // fighter->cleric dual
     PATCH_IF (("class" = 0x08) AND ("dualled_from_fighter" = 0x01) AND ("dualled_from_cleric" = 0x00)) THEN BEGIN
       SET "due" = ((0x04 + ("2nd_class_level" / 0x03)) + (0x02 + ("1st_class_level" / 0x04)))
       PATCH_IF ("current_total_profs" < "due") THEN BEGIN
         PATCH_IF (NOT ("1st_class_level" > "2nd_class_level")) THEN BEGIN
           PATCH_IF (NOT ("current_total_profs" > (0x04 + ("2nd_class_level" / 0x03)))) THEN BEGIN
             SET "fighter_due"       = ((0x04 + ("2nd_class_level" / 0x03)) - "current_total_profs")
             SET "cleric_due"        = (0x02 + ("1st_class_level" / 0x04))
             SET "dual_wrapup_due"   = 0x00
           END ELSE BEGIN
             SET "fighter_due"       = 0x00
             SET "cleric_due"        = ((0x02 + ("1st_class_level" / 0x04)) +  ((0x04 + ("2nd_class_level" / 0x03))) - "current_total_profs")
             SET "dual_wrapup_due"   = 0x00
           END
         END ELSE BEGIN
           PATCH_IF (NOT ("current_total_profs" > (0x04 + ("2nd_class_level" / 0x03)))) THEN BEGIN
             SET "fighter_due"       = ((0x04 + ("2nd_class_level" / 0x03)) - "current_total_profs")
             SET "cleric_due"        = (0x02 + ("2nd_class_level" / 0x04))
             PATCH_IF (("1st_class_level" = 0x04) OR ("1st_class_level" = 0x08) OR ("1st_class_level" = 0x0c) OR ("1st_class_level" = 0x10) OR ("1st_class_level" = 0x14) OR ("1st_class_level" = 0x18) OR ("1st_class_level" = 0x1c) OR ("1st_class_level" = 0x20) OR ("1st_class_level" = 0x24) OR ("1st_class_level" = 0x28) OR ("1st_class_level" = 0x2c) OR ("1st_class_level" = 0x30)) THEN BEGIN
               SET "dual_wrapup_due" = ((("1st_class_level" - "2nd_class_level") / 0x04) + 0x01)
             END ELSE BEGIN
               SET "dual_wrapup_due" = (("1st_class_level" - "2nd_class_level") / 0x04)
             END
           END ELSE PATCH_IF (NOT ("current_total_profs" > ((0x04 + ("2nd_class_level" / 0x03))) + (0x01 + ("2nd_class_level" / 0x06)))) THEN BEGIN
             SET "fighter_due"       = 0x00
             SET "cleric_due"        = ((0x02 + ("2nd_class_level" / 0x04)) +  ((0x04 + ("2nd_class_level" / 0x03))) - "current_total_profs")
             PATCH_IF (("1st_class_level" = 0x04) OR ("1st_class_level" = 0x08) OR ("1st_class_level" = 0x0c) OR ("1st_class_level" = 0x10) OR ("1st_class_level" = 0x14) OR ("1st_class_level" = 0x18) OR ("1st_class_level" = 0x1c) OR ("1st_class_level" = 0x20) OR ("1st_class_level" = 0x24) OR ("1st_class_level" = 0x28) OR ("1st_class_level" = 0x2c) OR ("1st_class_level" = 0x30)) THEN BEGIN
               SET "dual_wrapup_due" = ((("1st_class_level" - "2nd_class_level") / 0x04) + 0x01)
             END ELSE BEGIN
               SET "dual_wrapup_due" = (("1st_class_level" - "2nd_class_level") / 0x04)
             END
           END ELSE BEGIN
             SET "fighter_due"       = 0x00
             SET "cleric_due"        = 0x00
             SET "dual_wrapup_due"   = (((0x04 + ("2nd_class_level" / 0x03)) + (0x02 + ("1st_class_level" / 0x04))) - "current_total_profs")
           END
         END
         // berserker->cleric
         PATCH_IF          (("kit" = 0x40010000) OR ("kit" = 0x00010000)) THEN BEGIN
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~berserker_profs~
           END
           PATCH_IF ("cleric_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~cleric_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~berserker_cleric_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // wizardslayer->cleric
         END ELSE PATCH_IF (("kit" = 0x40020000) OR ("kit" = 0x00020000)) THEN BEGIN
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("cleric_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~cleric_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_cleric_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // kensai->cleric
         END ELSE PATCH_IF (("kit" = 0x40030000) OR ("kit" = 0x00040000)) THEN BEGIN
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~kensai_profs~
           END
           PATCH_IF ("cleric_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~cleric_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~kensai_cleric_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         // trueclass fighter->cleric
         END ELSE PATCH_IF (("kit" = 0x40000000) OR ("kit" = 0x00000000)) THEN BEGIN
           PATCH_IF ("fighter_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~fighter_profs~
           END
           PATCH_IF ("cleric_due" > 0x00) THEN BEGIN
             LAUNCH_PATCH_MACRO ~cleric_profs~
           END
           PATCH_IF ("dual_wrapup_due" > 0x00) THEN BEGIN
             SET "fighter_due" = "dual_wrapup_due"
             LAUNCH_PATCH_MACRO ~fighter_cleric_profs~
           END
           LAUNCH_PATCH_MACRO ~reindex_profs~
         END
       END
     END

Link to comment

Archived

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

×
×
  • Create New...