Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BG:EE/BG2:EE] Need to cast Find Familiar twice #9

Open
artifoxel opened this issue Jul 1, 2022 · 2 comments
Open

[BG:EE/BG2:EE] Need to cast Find Familiar twice #9

artifoxel opened this issue Jul 1, 2022 · 2 comments

Comments

@artifoxel
Copy link

artifoxel commented Jul 1, 2022

In BG:EE/BG2:EE, if you load a save or start a new game, you need to cast Find Familiar twice before the spell will succeed. (Not an issue on EET installs in my testing.) The problem seems to correct itself, if you rest once.

I think it is related to this code block in familiartobaldurbcs.baf (starting line 694).

IF
  Global("WTPFAMA1","GLOBAL",1)
  SpellCast([PC],WIZARD_FIND_FAMILAR)
  !SpellCast(%famsummoner%,WIZARD_FIND_FAMILAR)
THEN
  RESPONSE #100
    ActionOverride(%famsummoner%,DisplayString(Myself,24383))
    SetGlobal("WTPFAMA1","GLOBAL",0)
END

IF
  Global("WTPFAMA1","GLOBAL",1)
  SpellCast([PC],BEASTMASTER_FIND_FAMILIAR)
  !SpellCast(%famsummoner%,BEASTMASTER_FIND_FAMILIAR)
THEN
  RESPONSE #100
    ActionOverride(%famsummoner%,DisplayString(Myself,24383))
    SetGlobal("WTPFAMA1","GLOBAL",0)
END

I specifically lines it is these two conditions that seem to always trigger on the first cast, but not on the second.

  SpellCast([PC],WIZARD_FIND_FAMILAR)
  !SpellCast(%famsummoner%,WIZARD_FIND_FAMILAR)

or for Beast Masters:

  SpellCast([PC],BEASTMASTER_FIND_FAMILIAR)
  !SpellCast(%famsummoner%,BEASTMASTER_FIND_FAMILIAR)

Does anyone know of a fix for this small niggle? Thanks! 🦊

@artifoxel
Copy link
Author

Adding a bit more debugging testing:

  • Load game (w/FF memorized twice) -> Cast FF -> Fails -> Cast FF again -> Works
  • Load game -> Rest (w/FF memorized) -> Cast FF -> Works
  • Load game -> Rest (w/FF memorized) -> Quicksave -> Quickload -> Cast FF -> Fails

So something is being reset when loading a game that is preventing FF from casting successfully the first time.

Failing to cast FF once, or resting, seems to set the some variables that enable FF to be cast.

@artifoxel artifoxel changed the title BG:EE Need to cast Find Familiar twice [BG:EE/BG2:EE] Need to cast Find Familiar twice Jul 9, 2022
@artifoxel
Copy link
Author

artifoxel commented Jul 9, 2022

Hi all, I made a small patch to the protagonist cast checks in familiartobaldurbcs.baf to fix this issue.

original lines 694-733
IF
  Global("WTPFAMA1","GLOBAL",1)
  SpellCast([PC],WIZARD_FIND_FAMILAR)
  !SpellCast(%famsummoner%,WIZARD_FIND_FAMILAR)
THEN
  RESPONSE #100
    ActionOverride(%famsummoner%,DisplayString(Myself,8538))
    SetGlobal("WTPFAMA1","GLOBAL",0)
END

IF
  Global("WTPFAMA1","GLOBAL",1)
  SpellCast([PC],BEASTMASTER_FIND_FAMILIAR)
  !SpellCast(%famsummoner%,BEASTMASTER_FIND_FAMILIAR)
THEN
  RESPONSE #100
    ActionOverride(%famsummoner%,DisplayString(Myself,8538))
    SetGlobal("WTPFAMA1","GLOBAL",0)
END

IF
  Global("WTPFAMA1","GLOBAL",1)
  OR(5)
    TriggerOverride(Player1,Global("#GSCRFAI","LOCALS",1))
    TriggerOverride(Player2,Global("#GSCRFAI","LOCALS",1))
    TriggerOverride(Player3,Global("#GSCRFAI","LOCALS",1))
    TriggerOverride(Player4,Global("#GSCRFAI","LOCALS",1))
    TriggerOverride(Player5,Global("#GSCRFAI","LOCALS",1))
    TriggerOverride(Player6,Global("#GSCRFAI","LOCALS",1))
THEN
  RESPONSE #100
    ActionOverride(Player1,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(Player2,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(Player3,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(Player4,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(Player5,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(Player6,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(%famsummoner%,DisplayString(Myself,8538))
    SetGlobal("WTPFAMA1","GLOBAL",0)
END

patch (https://github.com/artyfox/WTPFamiliars/archive/refs/heads/master.zip)

IF
  Global("WTPFAMA1","GLOBAL",1)
  OR(10)
	SpellCast(Player2,WIZARD_FIND_FAMILAR)
	SpellCast(Player2,BEASTMASTER_FIND_FAMILIAR)
	SpellCast(Player3,WIZARD_FIND_FAMILAR)
	SpellCast(Player3,BEASTMASTER_FIND_FAMILIAR)
	SpellCast(Player4,WIZARD_FIND_FAMILAR)
	SpellCast(Player4,BEASTMASTER_FIND_FAMILIAR)
	SpellCast(Player5,WIZARD_FIND_FAMILAR)
	SpellCast(Player5,BEASTMASTER_FIND_FAMILIAR)
	SpellCast(Player6,WIZARD_FIND_FAMILAR)
	SpellCast(Player6,BEASTMASTER_FIND_FAMILIAR)
THEN
  RESPONSE #100
    ActionOverride(Myself,DisplayString(Myself,@1161)) // Protagonist only
    SetGlobal("WTPFAMA1","GLOBAL",0)
END

IF
  // #GSCRFAI set to 1 when Find Familiar cast from scroll 
  Global("WTPFAMA1","GLOBAL",1)
  OR(5)
    TriggerOverride(Player2,Global("#GSCRFAI","LOCALS",1))
    TriggerOverride(Player3,Global("#GSCRFAI","LOCALS",1))
    TriggerOverride(Player4,Global("#GSCRFAI","LOCALS",1))
    TriggerOverride(Player5,Global("#GSCRFAI","LOCALS",1))
    TriggerOverride(Player6,Global("#GSCRFAI","LOCALS",1))
THEN
  RESPONSE #100
    // must explicitly declare Player[N] to set local #GSCRFAI
    ActionOverride(Player2,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(Player3,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(Player4,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(Player5,SetGlobal("#GSCRFAI","LOCALS",0))
    ActionOverride(Player6,SetGlobal("#GSCRFAI","LOCALS",0))
    DisplayString(Myself,@1161) // Protagonist only
    SetGlobal("#GSCRFAI","GLOBAL",0) // undo #GSCRFAI 1 getting set as global for some reason
    SetGlobal("WTPFAMA1","GLOBAL",0)
END

ɴᴏᴛᴇ 1: I needed an explicit ActionOverride for each Player[N], because these alternatives didn't work
ActionOverride(Myself,SetGlobal("#GSCRFAI","LOCALS",0))
ActionOverride(LastTrigger,SetGlobal("#GSCRFAI","LOCALS",0))

ɴᴏᴛᴇ 2: For some reason, when Players 2-5 cast Find Familiar from scroll, the "#GSCRFAI" variable gets set to 1 as a global variable (in addition getting set as a local variable). But strangely, this doesn't happen when Player1 casts from scroll.

Overturning every leaf with NearInfinity, I'm pretty sure "#GSCRFAI" is only set as 1 from the first effect on SCRL6D.ITM, and that uses opcode #309 (0x135) Script: Modify Local Variable, so I'm stumpted. 😔

I'm new to IE scripting, so if anyone could explain why Myself and LastTrigger don't work, or how "#GSCRFAI" it is getting set as a global, I would be super appreciative! 🍪

artifoxel added a commit to artifoxel/WTPFamiliars that referenced this issue Jul 10, 2022
Fixes:
- Incorrect and missing StringRefs for BG:EE ([original issue tracker](Black-Wyrm-Lair#8))
- More consistent summoning checks for BG:EE ([original issue tracker](Black-Wyrm-Lair#9))
- Allow patching of `baldur.bcs` in BG:EE for "Release Familiar" from pack ([original issue tracker](Black-Wyrm-Lair#9))
artifoxel added a commit to artifoxel/WTPFamiliars that referenced this issue Jul 11, 2022
- Fix incorrect/missing strings for BG:EE (Black-Wyrm-Lair#8)
- More consistent summoning checks for BG(2):EE (Black-Wyrm-Lair#9)
- Allow patching of BG:EE `baldur.bcs` for "Release Familiar" item ability (Black-Wyrm-Lair#10)
artifoxel added a commit to artifoxel/WTPFamiliars that referenced this issue Jul 11, 2022
- Fix incorrect/missing strings for BGEE (Black-Wyrm-Lair#8)
- More consistent summoning checks for BG(2)EE (Black-Wyrm-Lair#9)
- Allow patching of BGEE `baldur.bcs` for "Release Familiar" item ability (Black-Wyrm-Lair#10)

*Switched to IESDP labels for game versions (without semicolon)
artifoxel added a commit to artifoxel/WTPFamiliars that referenced this issue Jul 11, 2022
- Fix incorrect/missing strings for BGEE (Black-Wyrm-Lair#8)
- More consistent summoning checks for BG(2)EE (Black-Wyrm-Lair#9)
- Allow patching of BGEE `baldur.bcs` for "Release Familiar" item ability (Black-Wyrm-Lair#10)

*Switched to IESDP labels for IE game variants (without semicolon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant