Jump to content

Improved handling of troll regeneration


argent77

Recommended Posts

On 10/11/2023 at 3:11 PM, argent77 said:

Relevant WeiDU code:

  Reveal hidden contents
// Intermediate filter spells
ACTION_DEFINE_ASSOCIATIVE_ARRAY reg_spl BEGIN
  // original SPL resref, cur. HP => intermediate SPL resref
  "trollreg", 12 => "#trollrg"
  "cdhgtrl", 12  => "#cdhgtrl"
  "cdtrlblz", 12 => "#cdtlblz"
  "cdtorgal", 12 => "#cdtorgl"
  "cdiwdtr1", 10 => "#cdidtr1"
  "cdiwdtr2", 10 => "#cdidtr2"
END

ACTION_PHP_EACH reg_spl AS keys => resref2 BEGIN
  OUTER_SPRINT resref1 $keys("0")
  OUTER_SET cur_hp = $keys("1")
  COPY_EXISTING "%resref1%.spl" "override/%resref2%.spl"
    LPF DELETE_SPELL_EFFECT
      INT_VAR opcode_to_delete = "-1" // all effects
    END
    LPF ADD_SPELL_EFFECT
      INT_VAR
        opcode = 318        // Protection from resource
        target = 1          // Self
        parameter1 = cur_hp
        parameter2 = 144    // STAT CURHITPOINTS >= [parameter1]
      STR_VAR
        resource = EVAL "%DEST_RES%"
    END
    LPF ADD_SPELL_EFFECT
      INT_VAR
        opcode = 146      // Cast spell
        target = 1        // Self
        parameter2 = 1    // Cast instantly (caster level)
        timing = 1        // Instant/Permanent until death
      STR_VAR
        resource = EVAL "%SOURCE_RES%"
    END
  IF_EXISTS
END


// Regeneration items
ACTION_DEFINE_ASSOCIATIVE_ARRAY reg_itm BEGIN
  // ITM resref => Intermediate SPL resref
  "trollreg" => "#TROLLRG"
  "cdhgtrl"  => "#CDHGTRL"
  "cdtrlblz" => "#CDTLBLZ"
  "cdtorgal" => "#cdtorgl"
  "reg1hp2"  => "#CDIDTR1"
  "cireve"   => "#CDIDTR2"
END

ACTION_PHP_EACH reg_itm AS resref1 => resref2 BEGIN
  COPY_EXISTING "%resref1%.itm" "override"
    LPF ADD_ITEM_EQEFFECT
      INT_VAR
        opcode = 232      // Cast spell on condition
        target = 1        // Self
        timing = 2        // While equipped
        parameter2 = 11   // TookDamage() / instant
      STR_VAR
        resource = EVAL "%resref2%"
    END
  BUT_ONLY IF_EXISTS
END

 

Good change. Due to the auto-pause bug, a more robust way is to fully embed it inside a 326 (p2=145, p1=2) rather than placing a 318 protection in front of the cast spell effect. The SPLPROT.2da entry is already there in all IE games.

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...