Jump to content

Possible issue with new component 'Sensible Regeneration When Traveling' (not yet released)


Recommended Posts

Posted (edited)

@CamDawg

I've tried the master from github and it looks like the script blocks added by this component block any script blocks added afterwards from executing.

Example from ar0015.bcs, the 2 creatures do not spawn:
 

IF
    !GlobalTimerExpired("cd_regen_short","GLOBAL")
    Global("cd_regen_area","GLOBAL",187)
THEN
    RESPONSE #100
        SetGlobalTimer("cd_regen_long","GLOBAL",TEN_TURNS)
        SetGlobalTimer("cd_regen_short","GLOBAL",FIVE_TURNS)
END

IF
    Global("h#SauterChateauSuif","AR0015",0)  // Kerzenburg
THEN
    RESPONSE #100
        SetGlobal("h#SauterChateauSuif","AR0015",1)  // Kerzenburg
        CreateCreature("h#schsui",[1186.659],NW)  // Wache
END

IF
    Global("g_bags","MYAREA",0)
THEN
    RESPONSE #100
        SetGlobal("g_bags","MYAREA",1)
        CreateCreature("g_bags",[2900.2900],N)  // Thorius
END

 

Edited by MikeX
Link to comment
Posted (edited)

[This post is almost entirely erroneous. See below.]

That's weird. I don't see any reason why those (mod-added) creatures wouldn't spawn on the second pass through the area script. The timers get set on the first pass, then that block's condition isn't met on the second pass and the remainder of the script can run.

Wait. Those locations. AR0015, in BG1, is a small indoors map. The whole thing fits into a rectangle from (0, 0) to (700, 450), and indeed only takes up about half of that area. You're not seeing those creatures because they spawn way out of bounds, in the black void you can't reach. Also, it would have been simpler to just add those creatures to the area as actors. (I'm assuming BG1, because BG2's AR0015 is part of the tutorial. But that's at least a larger area, so one of the creatures would show up in-bounds)

Still, there's an issue to fix with this component. It's inserting blocks at the beginning of area scripts. And because script blocks with the OnCreation() condition exist, all such broad-based script insertions should use Continue() in their actions. For example, when applied to Nashkel, this script insertion would prevent the brief "first visit" movie from ever playing.

Edited by jmerry
Link to comment

@jmerry

Thank you for looking into it.
I've forgot to mention, that I
'm on a BGT game and there ar0015.are is Candlekeep (main).
Above only the last part of the addition from the mention component is shown, the whole section would be this:

Spoiler
IF
    Global("cd_regen_area","GLOBAL",0)
THEN
    RESPONSE #100
        SetGlobalTimer("cd_regen_long","GLOBAL",TEN_TURNS)
        SetGlobalTimer("cd_regen_short","GLOBAL",FIVE_TURNS)
        SetGlobal("cd_regen_area","GLOBAL",187)
END

IF
    GlobalTimerExpired("cd_regen_long","GLOBAL")
    !Global("cd_regen_area","GLOBAL",187)
    OR(13)
        PartyHasItem("AX1H15")  // Axe of the Unyielding +5
        PartyHasItem("CLCK04")  // Cloak of the Wolf
        PartyHasItem("HELM18")  // Pearly White Ioun Stone
        PartyHasItem("LEAT23")  // Trollhide Armor +4
        PartyHasItem("MISCBC")  // Blackrazor +5
        PartyHasItem("OGREMASU")  // Katana +1
        PartyHasItem("RING31")  // Ring of Regeneration
        PartyHasItem("RING39")  // Ring of Gaxx
        PartyHasItem("RODMACE")  // Rod of Lordly Might +3
        PartyHasItem("RR#GUARA")  // Der Wächter
        PartyHasItem("RR#GUARB")  // Der Wächter
        PartyHasItem("RR#GUARC")  // Der Wächter
        PartyHasItem("THBELT01")  // I have a Cursed Berserking Sword +3. Certainly you can make something from it.
THEN
    RESPONSE #100
        ApplySpellRES("cdregen",Player1)  // No such index
        ApplySpellRES("cdregen",Player2)  // No such index
        ApplySpellRES("cdregen",Player3)  // No such index
        ApplySpellRES("cdregen",Player4)  // No such index
        ApplySpellRES("cdregen",Player5)  // No such index
        ApplySpellRES("cdregen",Player6)  // No such index
        SetGlobalTimer("cd_regen_long","GLOBAL",TEN_TURNS)
        SetGlobalTimer("cd_regen_short","GLOBAL",FIVE_TURNS)
        SetGlobal("cd_regen_area","GLOBAL",187)
END

IF
    GlobalTimerExpired("cd_regen_long","GLOBAL")
    !Global("cd_regen_area","GLOBAL",187)
    !PartyHasItem("AX1H15")  // Axe of the Unyielding +5
    !PartyHasItem("CLCK04")  // Cloak of the Wolf
    !PartyHasItem("HELM18")  // Pearly White Ioun Stone
    !PartyHasItem("LEAT23")  // Trollhide Armor +4
    !PartyHasItem("MISCBC")  // Blackrazor +5
    !PartyHasItem("OGREMASU")  // Katana +1
    !PartyHasItem("RING31")  // Ring of Regeneration
    !PartyHasItem("RING39")  // Ring of Gaxx
    !PartyHasItem("RODMACE")  // Rod of Lordly Might +3
    !PartyHasItem("RR#GUARA")  // Der Wächter
    !PartyHasItem("RR#GUARB")  // Der Wächter
    !PartyHasItem("RR#GUARC")  // Der Wächter
    !PartyHasItem("THBELT01")  // I have a Cursed Berserking Sword +3. Certainly you can make something from it.
THEN
    RESPONSE #100
        SetGlobalTimer("cd_regen_long","GLOBAL",TEN_TURNS)
        SetGlobalTimer("cd_regen_short","GLOBAL",FIVE_TURNS)
        SetGlobal("cd_regen_area","GLOBAL",187)
END

IF
    !GlobalTimerExpired("cd_regen_long","GLOBAL")
    !Global("cd_regen_area","GLOBAL",187)
THEN
    RESPONSE #100
        SetGlobalTimer("cd_regen_long","GLOBAL",TEN_TURNS)
        SetGlobalTimer("cd_regen_short","GLOBAL",FIVE_TURNS)
        SetGlobal("cd_regen_area","GLOBAL",187)
END

IF
    !GlobalTimerExpired("cd_regen_short","GLOBAL")
    Global("cd_regen_area","GLOBAL",187)
THEN
    RESPONSE #100
        SetGlobalTimer("cd_regen_long","GLOBAL",TEN_TURNS)
        SetGlobalTimer("cd_regen_short","GLOBAL",FIVE_TURNS)
END

 

Link to comment

Oh, wait. I misread that script block you copied in your first post. It resets the timers on every pass through the script, if the variable is set and the timers aren't expired. That, indeed, prevents any later blocks from running if its condition is met. Fix definitely needed. On my first read, I thought that was a !GlobalTimerNotExpired condition, which wouldn't have caused a problem.

(Also, it's not adding things to the beginning of the area script. It's adding them to the end, so Continue() isn't necessary.)

With added context ...

- At the first area visited, set a short and a long timer, and set a marker variable.

- Whenever the short timer expires (moving around an area), reset the short and long timer. At least, this is what would happen if that problem block had its condition flipped to GlobalTimerExpired or !GlobalTimerNotExpired. As it is, it just resets the timer on every pass through the script and prevents later blocks from running.

- If the marker variable isn't set (never), the party has a regeneration item that isn't restricted to one character, and the long timer is expired (the party just traveled or rested), apply a spell to all party members that simulates passing the regeneration item around to heal everybody. Then reset the timers. (The list of regeneration items appears to be dynamically generated, as it includes some mod items)

- If the marker variable isn't set (never), the party doesn't have a regeneration item, and the long timer is expired (the party just traveled or rested), then just reset the timers.

Well. In addition to the problem you noted, which is fixable by simply inverting one condition, the main blocks that should apply after rest or travel appear to have a problem as well. The marker variable condition they use means they'll never be valid, and this component doesn't do what it's supposed to. Until this component's scripting is fixed, nobody should use it.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...