Jump to content

Zed Nocear's Trigger-Simulations for BG1


Recommended Posts

Re: crash issues, I told my 1G switch to limit bandwidth to 10 and the problem went away. I've seen issues with Delay() causing sync errors in multiplayer before, and I see the ghoul script uses that. I'm going to give a shot at removing the script from ghoul and see if that resolves the matter.

 

 

I have read the issue and maybe the safety of Delay() in multiplayer is not absolute sure, but I doubt that Delay() is the reason of crashes in multiplayer. Delay() is used in original scripts about 50x in BG1 and 300x in BG2. Somehow should observe the crashes also in multiplayer in pure game. If slowing down the bandwidth has helped, I think, maybe outdated IPX protocol was not compliant with 1GHz bandwidth.

Link to comment

I have refreshed the code of AreaCheck emulation with using new feature of WeiDU: inline and evaluate_buffer. This version makes in principle exactly the same as the previous one, but has compacter, more clear code and is easer to use: only code, no separate BAF files are needed:

<<<<<<<< .../BG1TriggerEmulation-inlined/Z!EmulAreaCheck.BAF
IF
Delay(2)
ActionListEmpty()
THEN
RESPONSE #100
	SetGlobal("Z!EmulAreaCheck","GLOBAL",%Area_Number%)
	SetGlobal("Z!EmulAreaType","GLOBAL",%Area_Flags%)
	SetGlobal("Z!EmulAreaOutdoor","GLOBAL",%Variable_Outdoor%)
	SetGlobal("Z!EmulAreaCity","GLOBAL",%Variable_City%)
	SetGlobal("Z!EmulAreaForest","GLOBAL",%Variable_Forest%)
	SetGlobal("Z!EmulAreaDungeon","GLOBAL",%Variable_Dungeon%)
	SetGlobalTimer("Z!EmulAreaNotMaster","GLOBAL",4)
END
>>>>>>>>

<<<<<<<< .../BG1TriggerEmulation-inlined/Z!EmulAreaCheck1.BAF
IF
!Global("Z!EmulAreaCheck","GLOBAL",%Area_Number%)
!GlobalTimerNotExpired("Z!EmulAreaNotMaster","GLOBAL")
ActionListEmpty()
THEN
RESPONSE #100
	SetGlobal("Z!EmulAreaCheck","GLOBAL",%Area_Number%)
	SetGlobal("Z!LastMasterArea","GLOBAL",%Area_Number%)
	SetGlobal("Z!EmulAreaType","GLOBAL",%Area_Flags%)
	SetGlobal("Z!EmulAreaOutdoor","GLOBAL",%Variable_Outdoor%)
	SetGlobal("Z!EmulAreaCity","GLOBAL",%Variable_City%)
	SetGlobal("Z!EmulAreaForest","GLOBAL",%Variable_Forest%)
	SetGlobal("Z!EmulAreaDungeon","GLOBAL",%Variable_Dungeon%)
END
>>>>>>>>

COPY_EXISTING  ~AR2612.ARE~ ~override~ //two areas in BG1 have wrong flag "Outdoor"
		   ~AR3317.ARE~ ~override~
 WRITE_BYTE 0x48 0
 BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING_REGEXP GLOB ~.*\.ARE~ ~override~ // for all areas in game proper script name and file
 SPRINT area_name ~%SOURCE_RES%~
 READ_ASCII 0x94 ~old_script_name~
 WRITE_EVALUATED_ASCII 0x94 ~%SOURCE_RES%~
 INNER_ACTION BEGIN
ACTION_IF !(~%old_script_name%~ STRING_EQUAL_CASE ~%area_name%~)
	  AND (FILE_EXISTS_IN_GAME ~%old_script_name%.bcs~)
  THEN BEGIN COPY_EXISTING ~%old_script_name%.bcs~ ~override/%area_name%.bcs~ END
 END
 BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING_REGEXP GLOB ~.*\.ARE~ ~override~ // adds AreaCheck emulation block to the area script
 READ_ASCII 0x94 ~Script_Name~
 PATCH_IF (~%SOURCE_RES%~ STRING_MATCHES_REGEXP ~AR[0-9][0-9][0-9][0-9]~) = 0
THEN BEGIN READ_ASCII 0x96 ~Area_Number~ (4) END
ELSE BEGIN SPRINT ~Area_Number~ ~0~ END
 READ_BYTE 0x48 ~Area_Flags~
 INNER_ACTION BEGIN
ACTION_IF (NOT FILE_CONTAINS_EVALUATED(~%Script_Name%.BCS~ ~Z!EmulAreaCheck~)) // area script not already patched
  THEN BEGIN
	OUTER_SET Variable_Outdoor = ((~%Area_Flags%~ BAND 0b1) = 0b1)
	OUTER_SET Variable_City	= ((~%Area_Flags%~ BAND 0b1000) = 0b1000)
	OUTER_SET Variable_Forest  = ((~%Area_Flags%~ BAND 0b10000) = 0b10000)
	OUTER_SET Variable_Dungeon = ((~%Area_Flags%~ BAND 0b100000) = 0b100000)
	ACTION_IF (FILE_CONTAINS_EVALUATED(~MASTAREA.2DA~ ~%Script_Name%~))  //area is "master area" as in mastarea.2DA or not
	  THEN BEGIN EXTEND_BOTTOM ~%Script_Name%.BCS~ ~.../BG1TriggerEmulation-inlined/Z!EmulAreaCheck1.BAF~ EVALUATE_BUFFER END
	  ELSE BEGIN EXTEND_BOTTOM ~%Script_Name%.BCS~ ~.../BG1TriggerEmulation-inlined/Z!EmulAreaCheck.BAF~  EVALUATE_BUFFER END
END
 END
 BUT_ONLY_IF_IT_CHANGES

Inspired by Grogerson in his BG1 Tweaks, I present emulation of AreaCheck as one library-file TPA BG1areacheck_emulation.TPA.

Now the use of code is very simple, just include on the bottom of your mod TP2 code the line:

INCLUDE ~%PatchInMyMod%/BG1AreaCheck_emulation.tpa~

Link to comment
Re: crash issues, I told my 1G switch to limit bandwidth to 10 and the problem went away. I've seen issues with Delay() causing sync errors in multiplayer before, and I see the ghoul script uses that. I'm going to give a shot at removing the script from ghoul and see if that resolves the matter.

I have read the issue and maybe the safety of Delay() in multiplayer is not absolute sure, but I doubt that Delay() is the reason of crashes in multiplayer. Delay() is used in original scripts about 50x in BG1 and 300x in BG2. Somehow should observe the crashes also in multiplayer in pure game. If slowing down the bandwidth has helped, I think, maybe outdated IPX protocol was not compliant with 1GHz bandwidth.

 

Well, there is something about "Delay", but not Delay() at all. From my experience with "Areacheck Emulation" code, Delay(1) is buggy, works like True(), preventing fallowing script block activation and makes BG1 instable (sometimes CTD by area change and shopping). Delay with other time value like Delay(2) or higher works good.

Link to comment

So on the rest detection, only dplayer3.bcs is modified. Doesn't this mean that if a player disables party AI that there will never be rest detection? Which is the reason I'm assuming that the combat detection method not only modifies the dplayer2 & dplayer3 scripts but also modifies an override script for each npc in the game. so with that reasoning, do you not think that each npc's override script should have the block for rest detection as well for a backup for when party AI is turned off?

 

Oh and another thing, may I use the methodology but with completely different file names for a custom container? Leaving only one creature file that is scripted in all cases of the containers the same as used in TWM & BG1 Tweaks (Z!BAG0X.CRE). I don't think there would be a big problem as the container in question is going to be coded to remain with the joinable NPC.

Link to comment

If I remember correctly, dplayer3.bcs also triggers some sort of "Player1 monologue" in the original game. Are you sure it is disabled if party AI is switched off?

 

may I use the methodology but with completely different file names for a custom container?
If the file names are different it should be no problem coding wise. In case you were asking for permission, of course, please go ahead.
Link to comment

since dplayer3 & dplayer2 are identical with the exception that one is ran for built in npc joinables and the other is ran for multiplayer joinables & protagonist. And since there is a well documented cheat that you can bypass the 10 day time limit of the poisoning by Marek simply by turning off the party AI and never turning it back on, I'd hazard to guess that yes turning AI off will in fact turn both dplayer3 & dplayer2 off.

 

I have no clue what this "player 1 monologue" is in the original game. There are kickout and breaking point blocks for multiplayer joinables to give them the multig.dlg file and talk with the protagonist (player 1) for kicking them out or being of a rep too far for their liking. but no 'monologue'. dplayer2 has similar blocks but they don't set any dialog file as the built in npcs already have built in methods of changing dialog.

 

I think someone merely misunderstood what is going on with these two scripts

Link to comment

Archived

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

×
×
  • Create New...