Jump to content

Script Audit


Recommended Posts

This probably doesn't parse yet, and it very probably is illegible, but it's everything that turned up in a cursory run through of script patches for code that's not guarded against weidu.log deletion, EoU leftovers, or other snafus. What isn't here should be proof against fire and bombs through the roof.

 

There were only a couple other inauspicious OR() patches. There might be a genunine bug with the corrupt rufpal.bcs patch - it didn't match anything on my install, but the expression in the "// big, major script patch" did, so I've pasted them together.

 

There was one other, but I'm forgetting it now.

 

Still not crazy about the Drow Items loophole Closure going into baldur.bcs.

 

Anyway. No one really wanted this, but it's some drudgery to while away the hours until WeiDU 207 and A_B_P_O_R_B_B_O_O_O_J_A_S_R_S (Every dream is coming true!) Tear it all up, it needs it.

 

OUTER_PATCH ~this_is_not_a_variable~ BEGIN
 FOR (i1 = 0; i1 < 256; i1 += 1) BEGIN
WRITE_BYTE 0 i1
READ_ASCII 0 c (1)
SPRINT $0t(EVALUATE_BUFFER ~%i1%~) ~%c%~
 END
 SPRINT lnl ~%0t_10%~
END

DEFINE_PATCH_MACRO extend_bottom_if_absent BEGIN
 INNER_PATCH_FILE ~%extention%~ BEGIN
COMPILE_BAF_TO_BCS
READ_ASCII 3 script ELSE ~~ (BUFFER_LENGTH - 6)
QUOTE script_quote ~%script%~
 END
 COUNT_REGEXP_INSTANCES ~%script_quote%~ cri
 PATCH_IF cri < 1 BEGIN
INSERT_BYTES BUFFER_LENGTH STRING_LENGTH EVALUATE_BUFFER ~%script%~ - 3
WRITE_ASCIIE BUFFER_LENGTH - 3 ~%script%~
 END
END

DEFINE_PATCH_MACRO extend_top_if_absent BEGIN
 INNER_PATCH_FILE ~%extention%~ BEGIN
COMPILE_BAF_TO_BCS
READ_ASCII 3 script ELSE ~~ (BUFFER_LENGTH - 6)
QUOTE script_quote ~%script%~
 END
 COUNT_REGEXP_INSTANCES ~%script_quote%~ cri
 PATCH_IF cri < 1 BEGIN
INSERT_BYTES 3 STRING_LENGTH EVALUATE_BUFFER ~%script%~
WRITE_ASCIIE 3 ~%script%~
 END
END

// fix compile error
// Or don't, because this sure isn't used
/*
COPY_EXISTING ~IDIOT01.BCS~ ~override~
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY ~OR(31)~ ~OR(30)~
 COMPILE_BAF_TO_BCS
 BUT_ONLY_IF_IT_CHANGES
*/

// fix compile errors with bad numbers in OR blocks
COPY_EXISTING vicg.bcs  override
		  vicg1.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  OR(4)%lnl%	\(Global("ViconiaDeath","AR1000",1)\)%lnl%	\(Dead("Viconia")\)%lnl%THEN~
~ OR(2) \1 \2 THEN~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// this is duplicated a few patches further down, kill it
/*
COPY_EXISTING aerie.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY ~AreaType(0)~ ~AreaType(OUTDOOR)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
*/

COPY_EXISTING anomen.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^	SetGlobal("AnomenIsNotKnight","GLOBAL",1)~
~SetGlobal("AnomenIsNotKnight","GLOBAL",1) ChangeAlignment("Anomen",CHAOTIC_NEUTRAL)~
REPLACE_TEXTUALLY 
~"TALKEDTOCOR","GLOBAL"~
~"TalkedCor","GLOBAL"~
 COMPILE_BAF_TO_BCS
IF GLOBALTalkedToCor

// we might as well just REPLACE_BCS_BLOCK this wretched urticating script
// at least this way if someone's adding other triggers, they can
// just get \(matched\) \1 ... that is if we can find them :(
COPY_EXISTING jaheira.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^IF%lnl%  Global("TerminselSpawn","GLOBAL",2)%lnl%  See(\[PC\])%lnl%  GlobalLT("DerminSpawn","GLOBAL",5)%lnl%  !InParty(Myself)%lnl%THEN%lnl%  RESPONSE #100%lnl%	RealSetGlobalTimer("JaheiraRomance","GLOBAL",[^)]+)%lnl%	IncrementGlobal("LoveTalk","LOCALS",1)%lnl%	SetGlobal("DerminSpawn","GLOBAL",5)%lnl%	SetGlobalTimer("DerminAppear","GLOBAL",[^)]+)%lnl%	StartDialog\(ue\)?NoSet(\[PC\])%lnl%END~
~IF Global("TerminselSpawn","GLOBAL",2) See([PC]) GlobalLT("DerminSpawn","GLOBAL",5) !InParty(Myself) THEN RESPONSE #100 RealSetGlobalTimer("JaheiraRomance","GLOBAL",3600) SetGlobal("DerminSpawn","GLOBAL",5) SetGlobalTimer("DerminAppear","GLOBAL",17280) StartDialogueNoSet([PC]) END~
REPLACE_TEXTUALLY 
~^	SetGlobalTimer("TerminselAppear","GLOBAL",\(FIVE_DAYS\|36000\))~
~	RealSetGlobalTimer("TerminselAppear","GLOBAL",3600)~ // originally 36000 seems to be more than random.
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS ~16432 0 0 0 0 "" "" OB~ // False() trigger

COPY_EXISTING viconia.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  Global("LoveTalk","LOCALS",71)~
~  False()~
 COMPILE_BAF_TO_BCS
BUT_ONLY

ACTION_IF GAME_IS ~tob~ THEN BEGIN

 OUTER_SPRINT extention ~bg2fixpack/baf/anom25.baf~
 COPY_EXISTING anom25.bcs override
DECOMPILE_BCS_TO_BAF
  REPLACE_TEXTUALLY
  ~^  \(Global("AnomenSummoned","GLOBAL",1)\)~
  ~  \1 !Global("AnomenIsKnight","GLOBAL",1)~
COMPILE_BAF_TO_BCS
LAUNCH_PATCH_MACRO extend_top_if_absent
 BUT_ONLY
 UNLESS GLOBALAnomenIsKnight

 COPY_EXISTING jahe25.bcs override
DECOMPILE_BCS_TO_BAF
  REPLACE_TEXTUALLY 
  ~^  OR(2)%lnl%	\(GlobalGT("LoveTalk","LOCALS",50)\)%lnl%	\(Global("JaheiraRomanceActive","GLOBAL",2)\)~
  ~ !Global("JaheiraRomanceActive","GLOBAL",0) !Global("JaheiraRomanceActive","GLOBAL",3) OR(2) \1 \2~
COMPILE_BAF_TO_BCS
 BUT_ONLY

END

// UE not appearing bug
COPY_EXISTING ar0202.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY
~^  \(Global("UnseeingEye","GLOBAL",1)\)~
~ \1 Global("CDSpawnTheEyeOnlyOnce","GLOBAL",0)~
REPLACE_TEXTUALLY
~^	\(CreateCreature("BHEYE",\[2429\.1914\],0)\)~
~ \1 SetGlobal("CDSpawnTheEyeOnlyOnce","GLOBAL",1)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS GLOBALCDSpawnTheEyeOnlyOnce

// instead of a wait, change to timer for new block
COPY_EXISTING ar0205.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^	CreateCreature("BHEYE",\[2528\.1897\],12)~
~~
REPLACE_TEXTUALLY 
~^	Wait(~
~	SetGlobalTimer("CDUnseeingEyeAppears","AR0205",~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS CDUnseeingEyeAppears

// welther can spawn infinitely
COPY_EXISTING ar0400.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  \(Global("ElgeaGone","GLOBAL",0)\)~
~  \1 Global("ElgeaFree","GLOBAL",0)~
REPLACE_TEXTUALLY 
~^  GlobalTimerExpired("FindShagbag","GLOBAL")~
~  False()~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS ~16432 0 0 0 0 "" "" OB~ // False() trigger

// random Garrick stuff can prevent Bodhi's appearance
COPY_EXISTING ar0800.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  Global("GarrickSpeak","GLOBAL",1)~
~  False()~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS ~16432 0 0 0 0 "" "" OB~ // False() trigger

// unstakable vampire fix
COPY_EXISTING ar0801.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY
~^	SetGlobal("LassalVampires","GLOBAL",3)~
~~
REPLACE_TEXTUALLY 
~^	\(CreateCreatureDoor("bodhi2",\[480\.1338\],14)\)~
~ SetGlobal("LassalVampires","GLOBAL",3) \1~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// telwyn HoG exploit fix, pt 2/2 (see sctelwyn.d)
COPY_EXISTING sctelwyn.cre override
 REMOVE_CRE_ITEM helm03
BUT_ONLY

// terrece should only spawn if you speak to corneil, not just enter his area
COPY_EXISTING ar1000.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  \(Global("TerreceSpawn","GLOBAL",1)\)~
~ \1 Global("TalkedToCorneil","GLOBAL",1)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS GLOBALTalkedToCorneil

// ar1002 should check tolgerias' alternate DV
COPY_EXISTING ar1002.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY
~^  \(Dead("TOLGER")\)~
~  OR(2) \1 Dead("TOLGER2")~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS TOLGER2

// fixes Glacias charm issue
COPY_EXISTING ar1303.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY
~^	ApplySpell("kpglai01",WIZARD_TRUE_DISPEL_MAGIC)~
~	ActionOverride("kpglai01",ApplySpell("kpglai01",FORCE_DISPEL_MAGIC))~
REPLACE_TEXTUALLY
~^	ChangeEnemyAlly("kpglai01",NEUTRAL)~
~	ActionOverride("kpglai01",ChangeEnemyAlly(Myself,NEUTRAL))~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// asylum script bugs
COPY_EXISTING ar1515.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  \(Global("ppattackedJon","GLOBAL",1)\)~
~ \1 Global("WackoArmy","GLOBAL",0)~
REPLACE_TEXTUALLY
~^  \(Global("PPdeshSend","GLOBAL",0)\)~
~ OR(2) \1 Global("PirateRefused","GLOBAL",1)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS GLOBALPirateRefused

// Brynnlaw initial vamp fight should check for non-existence not dead
COPY_EXISTING ar1600.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~Dead("\(ppvalen\|ppparis\|ppdel\)")~
~!Exists("\1")~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// no-repeat Drizzt
ACTION_IF GAME_IS ~tob~ THEN BEGIN // ToB, much easier thanks to new action

 COPY_EXISTING ar2601.bcs override
DECOMPILE_BCS_TO_BAF
  REPLACE_TEXTUALLY 
  ~"DrizztEncounter","AR2601"~
  ~"DrizztEncounter","GLOBAL"~
  COUNT_REGEXP_INSTANCES ~SetEncounterProbability("AR2500","AR[01][037][02][04]",0)~ cri
  PATCH_IF cri < 4 BEGIN
	REPLACE_TEXTUALLY 
	~^	\(Explore()\)~
	~ \1 SetEncounterProbability("AR2500","AR0020",0) SetEncounterProbability("AR2500","AR1300",0) SetEncounterProbability("AR2500","AR1304",0) SetEncounterProbability("AR2500","AR1700",0)~
  END
COMPILE_BAF_TO_BCS
 BUT_ONLY

END ELSE BEGIN // SoA

 COPY_EXISTING ar2601.bcs override
INNER_PATCH_FILE ar0043.bcs  BEGIN
  READ_ASCII 3 script ELSE ~~ (BUFFER_LENGTH - 6)
  QUOTE script_quote ~%script%~
END
COUNT_REGEXP_INSTANCES ~%script_quote%~ cri
PATCH_IF cri < 1 BEGIN
  INSERT_BYTES SOURCE_SIZE - 3 STRING_LENGTH EVALUATE_BUFFER ~%script%~
  WRITE_ASCIIE SOURCE_SIZE - 3 ~%script%~
END
 BUT_ONLY

END

// script changes to ensure paladins/rangers fall in Hell tests; also closing selfish exploits
COPY_EXISTING ar2904.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~Global("\(Paladin\|Ranger\)Gone","AR2904"~
~Global("Abyss\1Gone","GLOBAL"~
REPLACE_TEXTUALLY 
~^  Class(Player1,RANGER_ALL)~
~ Class(Player1,RANGER_ALL) !Class(Player1,CLERIC_RANGER)~
REPLACE_TEXTUALLY 
~  \(OpenState("DOOR03",TRUE)\)~
~  \1 Global("OpenedDoor1","AR2904",1)~
REPLACE_TEXTUALLY 
~  \(OpenState("DOOR04",TRUE)\)~
~  \1 Global("OpenedDoor2","AR2904",1)~
REPLACE_TEXTUALLY 
~  \(OpenState("DOOR05",TRUE)\)~
~  \1 Global("OpenedDoor3","AR2904",1)~
REPLACE_TEXTUALLY 
~  \(OpenState("DOOR06",TRUE)\)~
~  \1 Global("OpenedDoor4","AR2904",1)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS GLOBALAbyssPaladinGone

// Viccy can romance half-orcs; multi-brus fixes
COPY_EXISTING baldur.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^	Race(Player1,0)~
~ Race(Player1,HALFORC)~
COUNT_REGEXP_INSTANCES ~!AreaCheck("AR0800")~ cri
PATCH_IF cri < 1 BEGIN
  REPLACE_TEXTUALLY 
  ~^  \(Global("SpawnBrus","GLOBAL",1)\)~
  ~ \1 Global("CHAPTER","GLOBAL",2) !AreaCheck("AR0800") !AreaCheck("AR2000") CombatCounter(0)~
END
COUNT_REGEXP_INSTANCES ~SetGlobal("SPAWNBRUS","GLOBAL",2)~ cri
PATCH_IF cri < 1 BEGIN
  REPLACE_TEXTUALLY 
  ~^	\(CreateCreatureObjectOffScreen("BRUS3",Player1,0,0,0)\)~
  ~ \1 SetGlobal("SPAWNBRUS","GLOBAL",2)~
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// wot?
COPY_EXISTING brannel.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  Global("LathanPlot\(1\|2\)","GLOBAL",1)~
~  Global("LathanPlot","GLOBAL",\1)~
REPLACE_TEXTUALLY 
~^	StartDialog\(ue\)?NoSet(Myself)~
~	StartDialogueNoSet(Player1)~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// remove minhp1 for a moment to allow bodhi's str decrease to take effect
COPY_EXISTING c6bweak.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^	\(ApplySpell(Myself,C6BODHI_WEAKNESS)\)~
~ TakeItemReplace("monhp1","minhp1",Myself) \1 TakeItemReplace("minhp1","monhp1",Myself)~
REPLACE_TEXTUALLY 
~^	DestroyItem("VAMPREG3")~
~ DestroyItem("VAMPREG2")~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS monhp1

// valen's premature death prevents Del changing from bat form and attacking
COPY_EXISTING c6valen.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^	\(ReallyForceSpellDead(Myself,VALEN_MIST_FORM_CHANGE)\)%lnl%END~
~ SetGlobal("ValenFight","AR0808",1) \1 END~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// cromwell cutscene; removes multi-forged item bug
COPY_EXISTING ~cromwell.bcs~ ~override~
 DECOMPILE_BCS_TO_BAF
COUNT_REGEXP_INSTANCES ~^	CutSceneId("wsmith01")%lnl%	ClearAllActions()~ cri
PATCH_IF cri < 1 BEGIN
  REPLACE_TEXTUALLY 
  ~^	\(CutSceneId("wsmith01")\)~ 
  ~ \1 ClearAllActions()~
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// rest commands not executed due to DayNight flakiness
COPY_EXISTING ~cut41c.bcs~ ~override~
		  ~cut41d.bcs~ ~override~
 DECOMPILE_BCS_TO_BAF
COUNT_REGEXP_INSTANCES ~^	Wait(1)%lnl%	Rest()~ cri
PATCH_IF cri < 1 BEGIN
  REPLACE_TEXTUALLY  
  ~^	\(Rest()\)~ 
  ~ Wait(1) \1~
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// part of desharik's xp exploit fix, see ppdesh in the d file
COPY_EXISTING cut41f.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^	\(SetGlobal("EnteredArea1500","GLOBAL",1)\)~
~ \1 AddXPObject(Player1,38500) AddXPObject(Player2,38500) AddXPObject(Player3,38500) AddXPObject(Player4,38500) AddXPObject(Player5,38500) AddXPObject(Player6,38500)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS ~259OB~

// ust natha scenery cutscene can occur offscreen, meaning player stands in dark for no apparent reason
COPY_EXISTING dadrow20.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^	\(StartCutSceneMode()\)~
~ \1 CreateCreature("cutspy",[3864.273],0) MoveViewPoint([3864.273],INSTANT)~
REPLACE_TEXTUALLY 
~^	\(EscapeArea()\)~
~ \1 ActionOverride("cutspy",DestroySelf()) MoveViewObject(Player1,INSTANT)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS cutspy

// edwin soundset issues for transformation
COPY_EXISTING edwin.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~	\(SetPlayerSound(Myself\),30716,\(SELECT_ACTION4)\)~ 
~	\1,30715,\2~
REPLACE_TEXTUALLY 
~	\(SetPlayerSound(Myself\),30717,\(SELECT_ACTION5)\)~ 
~	\1,3984,\2~
REPLACE_TEXTUALLY 
~	\(SetPlayerSound(Myself\),30718,\(SELECT_ACTION6)\)~ 
~	\1,3985,\2~
REPLACE_TEXTUALLY 
~	\(SetPlayerSound(Myself\),30719,\(SELECT_ACTION7)\)~ 
~	\1,3986,\2~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// containers can summon guards days after they're open
COPY_EXISTING enforam.bcs override
		  tempv01.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  OR(2)%lnl%	!See(\[NOTGOOD\])	Global("warn","LOCALS",1)~
~  GlobalTimerExpired("CDGoAway","LOCALS")~
REPLACE_TEXTUALLY 
~^  \(Global("warn","LOCALS",0)\)~
~ \1 GlobalTimerNotExpired("CDGoAway","LOCALS")~
REPLACE_TEXTUALLY 
~^	Wait(5)~
~~
REPLACE_TEXTUALLY 
~^  See(\[NEUTRAL\])~
~  See([NEUTRAL.HUMANOID])~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS CDGoAway

// other gladiators should do something when Hendak does
COPY_EXISTING glad2782.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  \(Dead("Hendak")\)~
~ OR(2) \1 Allegiance("Hendak",255)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS ~16395 255 0 0 0 "" "" OB~ // allegiance trigger

// lavok dying too early because of this cheese script
// False()d rather than unassigned in case someone wants to use this for lavok02-specific scripting
COPY_EXISTING lavok02.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY ~!HasItem("MINHP1",Myself)~ ~False()~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// fixes breaking bridge in UE quest
COPY_EXISTING riftg01.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~^  !Dead("Riftcr0[23]")~
~  False()~
REPLACE_TEXTUALLY
~^  !Dead("Riftcr01")~
~  Dead("Riftcr01")~
REPLACE_TEXTUALLY
~^  !Exists("Riftcr01")~
~ CombatCounter(0) OR(2) !Exists("Riftcr03") Dead("Riftcr03") OR(2) !Exists("Riftcr02") Dead("Riftcr02") OR(2) !Exists("Riftcr01")~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// amalas' buddies should leave together if you kill him
COPY_EXISTING rufpal.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~Global("\(itFight\|R0406PitFight\)"),"\(R0406P\|\)",3)~
~Global("PitFight","AR0406",3)~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// avatar of rilifane xp exploit fix
COPY_EXISTING sustatue.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~  \(Contains("MISCB3",Myself)\)~
~ \1 Global("CDNoRepeat","AR2803",0)~
REPLACE_TEXTUALLY 
~	\(TriggerActivation("Tran2800",FALSE)\)~
~ SetGlobal("CDNoRepeat","AR2803",1) \1~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS AR2803CDNoRepeat

// stops Terrece from initiating dialogue from outside
COPY_EXISTING terrece.bcs override
 DECOMPILE_BCS_TO_BAF
COUNT_REGEXP_INSTANCES ~See(\[PC\])~ cri
PATCH_IF cri = 0 BEGIN
  REPLACE_TEXTUALLY 
  ~^  \(Global("TerreceSpawn","GLOBAL",2)\)~
  ~  \1 See([PC])~
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// summoned juggernaut golem shouldn't die instantly if summoned by clone
COPY_EXISTING tomegol4.bcs override
 DECOMPILE_BCS_TO_BAF
COUNT_REGEXP_INSTANCES ~  !CheckStatGT(LastSummonerOf(Myself),0,STONESKINSGOLEM)~ cri
PATCH_IF cri = 0 BEGIN
  REPLACE_TEXTUALLY 
  ~  \(!CheckStatGT(Player1,0,STONESKINSGOLEM)\)~
  ~ !CheckStatGT(LastSummonerOf(Myself),0,STONESKINSGOLEM) \1~
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// removes bug of losing rogue stone if reloaded
COPY_EXISTING tran1008.bcs override
 DECOMPILE_BCS_TO_BAF
COUNT_REGEXP_INSTANCES ~	ActionOverride(Player1,LeaveAreaLUAPanic("AR1008","",\[495\.755\],10))%lnl%	TakePartyItem("MISC45")~ cri
PATCH_IF cri = 0 BEGIN
  REPLACE_TEXTUALLY 
  ~^	TakePartyItem("MISC45")~
  ~~
  REPLACE_TEXTUALLY 
  ~^	\(ActionOverride(Player1,LeaveAreaLUAPanic("AR1008","",\[495\.755\],10))\)~
  ~ \1 TakePartyItem("MISC45")~
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// endless Ust Natha tavern combat music
COPY_EXISTING ucounter.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~  \(SetGlobal("HaltMusicWithLesaonar","GLOBAL"\),0)~
~  \1,2)~
REPLACE_TEXTUALLY 
~  \(CombatCounterLT(50)%lnl%  Global("HaltMusicWithLesaonar","GLOBAL",\)0)~
~\12)~
 COMPILE_BAF_TO_BCS
BUT_ONLY

// prevent journal entry for already-opened UD illithid doors
COPY_EXISTING uddoor2.bcs ~override~
		  uddoor3.bcs ~override~
 DECOMPILE_BCS_TO_BAF
PATCH_FOR_EACH n IN ~~ ~2~ BEGIN
  COUNT_REGEXP_INSTANCES ~^  Global("thrallDoorMes%n%","AR2400",0)%lnl%  Global("thrallDoorOpen%n%","AR2400",0)~ cri
  PATCH_IF cri = 0 BEGIN
	REPLACE_TEXTUALLY 
	~^  Global("thrallDoorMes%n%","AR2400",0)~
	~ Global("thrallDoorMes%n%","AR2400",0) Global("thrallDoorOpen%n%","AR2400",0)~
  END
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// Ust Natha egg guards no longer see invisible folks
COPY_EXISTING udeggs.bcs override
 DECOMPILE_BCS_TO_BAF
COUNT_REGEXP_INSTANCES ~^  GlobalTimerExpired("eggGuardDoesWarn","GLOBAL")%lnl%  See(\[PC\])~ cri
PATCH_IF cri = 0 BEGIN
  REPLACE_TEXTUALLY 
  ~  \(GlobalTimerExpired("eggGuardDoesWarn","GLOBAL")\)~
  ~  \1%lnl%  See([PC])~
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// uhleave5 and 6 should be moving between areas, opening doors, etc.
COPY_EXISTING uhleave5.bcs override
		  uhleave6.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~	MoveToPointNoInterrupt(\[\(805\|709\)\.\(407\|301\)\])~
~	MoveToPointNoInterrupt([\1.\2]) Unlock("DOOR02") OpenDoor("DOOR02")~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS DOOR02

// Valygar only goes hostile if mazzy is hostile and not charmed
// valygar goes hostile if something happens to hervo, but should leave the party first
COPY_EXISTING valygar.bcs override
 DECOMPILE_BCS_TO_BAF
COUNT_REGEXP_INSTANCES ~!StateCheck("Mazzy",STATE_CHARMED)~ cri
PATCH_IF cri = 0 BEGIN
  REPLACE_TEXTUALLY 
  ~  \(Allegiance("Mazzy",ENEMY)\)~
  ~ \1 !StateCheck("Mazzy",STATE_CHARMED)~
  REPLACE_TEXTUALLY 
  ~	\(SetGlobal("vgAttackTheParty","LOCALS",1)\)~
  ~ \1 LeaveParty()~
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// Valygar leaving party in Slums can cause cutscene hang
COPY_EXISTING valyorb.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~  IsOverMe(\("Valygar"\))~
~  IsOverMe(\1) InParty(\1) IsValidForPartyDialogue(\1) !StateCheck(\1,STATE_SLEEPING)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS ~16451 0 0 0 0 "" "" OB~ // InParty() trigger

// prevents viekang's double dialogue
COPY_EXISTING viekang.bcs override
 DECOMPILE_BCS_TO_BAF
COUNT_REGEXP_INSTANCES ~  Global("Attacked","LOCALS",0)%lnl%  !Global("ViekangSeesPC","LOCALS",1)~ cri
PATCH_IF cri = 0 BEGIN
  REPLACE_TEXTUALLY 
  ~  \(Global("Attacked","LOCALS",0)\)~
  ~ \1 !Global("ViekangSeesPC","LOCALS",1)~
END
 COMPILE_BAF_TO_BCS
BUT_ONLY

// closes Yoshimo exploit of resurrecting him after Spellhold
COPY_EXISTING yoshimo.bcs override
 DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY 
~	\(Kill(Myself)\)~
~ \1 LeaveParty()~
 COMPILE_BAF_TO_BCS
BUT_ONLY
UNLESS EVALUATE_BUFFER ~^21AC%lnl%~ // LeaveParty()

ACTION_IF FILE_EXISTS_IN_GAME ~mel01.cre~ THEN BEGIN // ToB check

 // part of the multi-holy symbol exploit fix. Also needed: CDHLYSYM.spl, CDHLYSY2.spl, CDHLYSYM.itm, and clabpr02-04 changes.
 OUTER_SPRINT extention ~bg2fixpack/baf/holysym.baf~
 COPY_EXISTING baldur.bcs   override
			baldur25.bcs override
LAUNCH_PATCH_MACRO extend_top_if_absent
 BUT_ONLY

 // if killed directly via spell, fire trolls should do groovy death animations
 OUTER_SPRINT extention ~bg2fixpack/baf/hgtrl01.baf~
 COPY_EXISTING hgtrl01.bcs override
LAUNCH_PATCH_MACRO extend_top_if_absent
 BUT_ONLY

 // moves LOCALS var set to local script instead of ar4500
 OUTER_SPRINT extention ~bg2fixpack/baf/keld25.baf~
 COPY_EXISTING keld25.bcs override
LAUNCH_PATCH_MACRO extend_top_if_absent
 BUT_ONLY

 // sarevok soundset fixes
 EXTEND_BOTTOM sarev25.bcs ~bg2fixpack/baf/sarev25.baf~

END

ACTION_DEFINE_ASSOCIATIVE_ARRAY e_t_i_a BEGIN
 anomen.bcs   => ~bg2fixpack/baf/anomen.baf~   // avoiding block duplication
 ar0411.bcs   => ~bg2fixpack/baf/ar0411.baf~   // Teos/Planar Sphere fix
 ar0415.bcs   => ~bg2fixpack/baf/ar0415.baf~   // Tyrianna fix, part 1 (second is plgirl01.cre patch)
 enforam.bcs  => ~bg2fixpack/baf/enforam.baf~  // containers can summon guards days after they're open
 tempv01.bcs  => ~bg2fixpack/baf/enforam.baf~  // containers can summon guards days after they're open
 garren.bcs   => ~bg2fixpack/baf/garren.baf~   // double Garren Windspears
 ilyich.bcs   => ~bg2fixpack/baf/ilyich.baf~   // Ilyich actually wears his imported armor
 killpc.bcs   => ~bg2fixpack/baf/killpc.baf~   // Arkanis Gath should not spawn and kill the PC post-Brynnlaw
 madeen.bcs   => ~bg2fixpack/baf/madeen.baf~   // Madeen should go away if Tolgerias dead--check for other DV
 mvally2.bcs  => ~bg2fixpack/baf/mvally2.baf~  // disables Gath spawn
 riftcr04.bcs => ~bg2fixpack/baf/riftcr04.baf~ // emphatic manifestation can be killed by resting outside
 sumdj01.bcs  => ~bg2fixpack/baf/sumdj01.baf~  // ring of djinni summoning should destroy ring if djinni dies
 teardoor.bcs => ~bg2fixpack/baf/teardoor.baf~ // alignment change if evil path in hell trials; other fixes in ar2900.bcs
 tolger.bcs   => ~bg2fixpack/baf/tolger.baf~   // multiple ring of the ram exploit fixes
 trrak01.bcs  => ~bg2fixpack/baf/trrak01.baf~  // trrakxx should have dialogue when attacked
 uhleave5.bcs => ~bg2fixpack/baf/uhleave5.baf~ // uhleave5 and 6 should be moving between areas, opening doors, etc.
 uhleave6.bcs => ~bg2fixpack/baf/uhleave6.baf~ // uhleave5 and 6 should be moving between areas, opening doors, etc.
END

ACTION_PHP_EACH e_t_i_a AS game_script => extention BEGIN
 ACTION_IF FILE_EXISTS_IN_GAME ~%game_script_0%~ THEN BEGIN
COPY_EXISTING ~%game_script_0%~ override
  LAUNCH_PATCH_MACRO  extend_top_if_absent
BUT_ONLY
 END
END

ACTION_DEFINE_ASSOCIATIVE_ARRAY e_b_i_a BEGIN
 ar0020.bcs   => ~bg2fixpack/baf/ar0020.baf~   // Flydian shouldn't hang around asking folks to save Trademeet after it's already been saved
 ar0205.bcs   => ~bg2fixpack/baf/ar0205.baf~
 ar0321.bcs   => ~bg2fixpack/baf/ar032x.baf~   // allows resting in thieves guild stronghold
 ar0322.bcs   => ~bg2fixpack/baf/ar032x.baf~   // allows resting in thieves guild stronghold
 ar0323.bcs   => ~bg2fixpack/baf/ar032x.baf~   // allows resting in thieves guild stronghold
 ar0324.bcs   => ~bg2fixpack/baf/ar032x.baf~   // allows resting in thieves guild stronghold
 ar0400.bcs   => ~bg2fixpack/baf/ar0400.baf~   // Shagbag's always-true block disables half the area script
 ar0705.bcs   => ~bg2fixpack/baf/ar0705.baf~   // death of Mekrath not clearing journal entries; see mekrat.dlg
 ar0800.bcs   => ~bg2fixpack/baf/ar0800.baf~   // random Garrick stuff can prevent Bodhi's appearance
 ar0801.bcs   => ~bg2fixpack/baf/ar0801.baf~   // Bodhi broken if saved during her wait()-laden spawn;
 ar0903.bcs   => ~bg2fixpack/baf/ar0903.baf~   // allows resting in Paladin stronghold
 ar1002.bcs   => ~bg2fixpack/baf/ar1002.baf~   // Ketlaar Argrim and his bodyguards go away from the Council building if he's imprisoned
 ar1008.bcs   => ~bg2fixpack/baf/ar1008.baf~   // no escape from teh Twisted Room
 ar2900.bcs   => ~bg2fixpack/baf/ar2900.baf~   // alignment change if evil path in hell trials; other fixes in teardoor.bcs
 ar2901.bcs   => ~bg2fixpack/baf/ar2901.baf~   // script changes to ensure paladins/rangers fall in Hell tests;
 ar2902.bcs   => ~bg2fixpack/baf/ar2902.baf~   // also closing selfish exploits
 ar2903.bcs   => ~bg2fixpack/baf/ar2903.baf~
 baldur.bcs   => ~bg2fixpack/baf/baldur.baf~   // drow item exploits closed
 cernd.bcs	=> ~bg2fixpack/baf/cernd.baf~	// Cernd goes hostile if Grove poisoned
 glad2782.bcs => ~bg2fixpack/baf/glad2782.baf~ // other gladiators should do something when Hendak does
 lavok02.bcs  => ~bg2fixpack/baf/lavok02.baf~  // lavok dying too early because of this cheese script
 ucounter.bcs => ~bg2fixpack/baf/ucounter.baf~ // endless Ust Natha tavern combat music
END

ACTION_PHP_EACH e_b_i_a AS game_script => extention BEGIN
 ACTION_IF FILE_EXISTS_IN_GAME ~%game_script_0%~ THEN BEGIN
COPY_EXISTING ~%game_script_0%~ override
  LAUNCH_PATCH_MACRO  extend_bottom_if_absent
BUT_ONLY
 END
END

 

Thank you code tags for breaking board formatting.

Link to comment
Don't be surprised if converting all of the linebreaks and spaces to avoid codebox de-formatting broke something though.

Huh? I'm not getting this one.

Always thought that codebox just adds some CSS to the div (probably 'overflow:auto') to get the browser to display scrollbars and everything else is the same.

 

But anyway, we should get back on topic and do some auditing.

Link to comment

Since I'm unqualified to talk about fixpack stuff, I will concentrate on WeiDU things.

You are certainly someone who uses WeiDU code nobody else does. :laugh:

 

Two things about your extend_bottom_if_absent macro:

1.

INSERT_BYTES BUFFER_LENGTH STRING_LENGHT EVALUATE_BUFFER ~%script%~ - 3

should probably look like

INSERT_BYTES BUFFER_LENGTH - 3 STRING_LENGTH EVALUATE_BUFFER ~%script%~

since you don't want to override that last "SC\n".

 

2. I think BUFFER_LENGTH will always evaluate to the current buffer length. So if you insert some bytes in the buffer, it will be (old_buffer_length + inserted_bytes_length). So you probably get a write out of bounds.

So:

SET ~buffer_length~ = BUFFER_LENGTH
INSERT_BYTES buffer_length - 3 STRING_LENGTH EVALUATE_BUFFER ~%script%~
WRITE_ASCIIE buffer_length - 3 ~%script%~

Link to comment

That one isn't the board's fault, it's my deciding that it'd be better to allow running during other patches and changing from SOURCE_SIZE to BUFFER_LENGTH without finishing what I'd started. Oh well.

 

I suppose what we really want is emulating the behavior of EXTEND_* on zero byte files, so

DEFINE_PATCH_MACRO extend_bottom_if_absent BEGIN
 SET insert = (BUFFER_LENGTH > 2 ? BUFFER_LENGTH - 3 : 0)
 SPRINT script ~~
 INNER_PATCH_FILE ~%extention%~ BEGIN
COMPILE_BAF_TO_BCS
PATCH_IF BUFFER_LENGTH - 12 > 0 BEGIN
  READ_ASCII 3 script ELSE ~~ (BUFFER_LENGTH - 6)
END
 END
 PATCH_IF ~~ STR_CMP ~%script%~ BEGIN
COUNT_REGEXP_INSTANCES ~%script%~ cri
PATCH_IF cri < 1 BEGIN
  INSERT_BYTES insert STRING_LENGTH EVALUATE_BUFFER ~%script%~
  WRITE_ASCIIE insert ~%script%~
END
 END
END

DEFINE_PATCH_MACRO extend_top_if_absent BEGIN
 SET insert = (BUFFER_LENGTH > 2 ? 3 : 0)
 SPRINT script ~~
 INNER_PATCH_FILE ~%extention%~ BEGIN
COMPILE_BAF_TO_BCS
PATCH_IF BUFFER_LENGTH - 12 > 0 BEGIN
  READ_ASCII 3 script ELSE ~~ (BUFFER_LENGTH - 6)
END
 END
 PATCH_IF ~~ STR_CMP ~%script%~ BEGIN
COUNT_REGEXP_INSTANCES ~%script%~ cri
PATCH_IF cri < 1 BEGIN
  INSERT_BYTES insert STRING_LENGTH EVALUATE_BUFFER ~%script%~
  WRITE_ASCIIE insert ~%script%~
END
 END
END

 

is better yet. Other than the broken ("PC]) triggers we fix beforehand, there are no regexp reserved characters in scripts, so we can dump the QUOTE business and not SET install_time = (3 * install_time) / 2.

 

I'll see if I can't rummage through the beta fixes today.

Link to comment

I suppose one of the sticky points may be how many Dornerisms need to stay canonized in the fixpack. I really dislike adding False() triggers, but it's a method that demonstrably works, and not going that route might indeed cause people trying to use R_B_B to fail patches (more often than they already do) :laugh:

 

While the Dawg's away the mice will have their say, though.

Link to comment

Archived

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

×
×
  • Create New...