City of Arabel
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Charm Person Duration is wrong.

    Scheduled Pinned Locked Moved Closed Bugs
    2 Posts 2 Posters 65 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SpiffyMeisterS
      SpiffyMeister
      last edited by SpiffyMeister

      Presently, the duration is 10 rounds + caster level /always/.

      The default duration should be 2 rounds plus (CasterLevel/3)

      This is a bug in the script that defaults to greater spell focus enchantment duration.

      Here is the fixed code.

      //:: [Charm Person]
      //:: [NW_S0_CharmPer.nss]
      //:: Copyright (c) 2000 Bioware Corp.
      //:://////////////////////////////////////////////
      //:: Will save or the target is charmed for 1 round
      //:: per caster level.
      //:://////////////////////////////////////////////
      //:: Created By: Preston Watamaniuk
      //:: Created On: Jan 29, 2001
      //:: Last Updated By: Preston Watamaniuk, On: April 10, 2001
      //:: VFX Pass By: Preston W, On: June 20, 2001
      //:: Modified By: Fargle, On: 11/26/19
      //:Modified by Spiffy on: 5/26/2025
      //::                Now turns humanoid NPCs non-hostile over duration
      //::                Duration changes based on SF/GSF Enchantment
      //:                  Fixed bug in duration.
      //:://////////////////////////////////////////////
      
      #include "NW_I0_SPELLS"
      #include "x2_inc_spellhook"
      
      // CoA-specific include, needed for GetFaction()
      #include "inc_factiontools"
      
      void main()
      {
          // Spell hook check
          if (!X2PreSpellCastCode())
          {
              return;
          }
      
          // Major variables
          object oTarget = GetSpellTargetObject();
          effect eVis = EffectVisualEffect(VFX_IMP_CHARM);
          effect eCharm = EffectCharmed();
          eCharm = GetScaledEffect(eCharm, oTarget);
          effect eMind = EffectVisualEffect(VFX_DUR_MIND_AFFECTING_NEGATIVE);
          effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
          effect eLink = EffectLinkEffects(eMind, eCharm);
          eLink = EffectLinkEffects(eLink, eDur);
      
          // Spell Focus checks
          int bHasSFEn = GetHasFeat(FEAT_SPELL_FOCUS_ENCHANTMENT, OBJECT_SELF);
          int bHasGSFEn = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_ENCHANTMENT, OBJECT_SELF);
          object oOriginalFaction = GetFaction(oTarget);
      
          int nMetaMagic = GetMetaMagicFeat();
          int nCasterLevel = GetAdjustedCasterLevel(OBJECT_SELF);
          int nDuration = 2 + nCasterLevel / 3; // Default fallback duration
      
          // Custom duration logic based on feats
          if (bHasGSFEn == TRUE) //Bug fixed here.
          {
              nDuration = nCasterLevel + 10; // 1 round per level + 10
          }
          else if (bHasSFEn == TRUE)
          {
              nDuration = nCasterLevel; // 1 rounds per level
          }
      
          // Apply Extend Spell doubling
          if (nMetaMagic == METAMAGIC_EXTEND)
          {
              nDuration = nDuration * 2;
          }
      
          // Scale the duration based on internal rules
          nDuration = GetScaledDuration(nDuration, oTarget);
      
          // Debug message for developers
          //SendMessageToPC(GetFirstPC(), "Charm Duration (Rounds): " + IntToString(nDuration));
      
          int nRacial = GetRacialType(oTarget);
      
          // Check target disposition
          if (!GetIsReactionTypeFriendly(oTarget))
          {
              SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_CHARM_PERSON, FALSE));
      
              // Spell resistance check
              if (!MyResistSpell(OBJECT_SELF, oTarget))
              {
                  // Humanoid racial type check
                  if ((nRacial == RACIAL_TYPE_DWARF) ||
                      (nRacial == RACIAL_TYPE_ELF) ||
                      (nRacial == RACIAL_TYPE_GNOME) ||
                      (nRacial == RACIAL_TYPE_HUMANOID_GOBLINOID) ||
                      (nRacial == RACIAL_TYPE_HALFLING) ||
                      (nRacial == RACIAL_TYPE_HUMAN) ||
                      (nRacial == RACIAL_TYPE_HALFELF) ||
                      (nRacial == RACIAL_TYPE_HALFORC) ||
                      (nRacial == RACIAL_TYPE_HUMANOID_MONSTROUS) ||
                      (nRacial == RACIAL_TYPE_HUMANOID_ORC) ||
                      (nRacial == RACIAL_TYPE_HUMANOID_REPTILIAN))
                  {
                      // Will save check
                      if (!MySavingThrow(SAVING_THROW_WILL, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_MIND_SPELLS))
                      {
                          if (GetIsPC(oTarget))
                          {
                              // Apply charm to PC
                              ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, RoundsToSeconds(nDuration));
                          }
                          else
                          {
                              // NPC behavior override: make non-hostile, restore faction later
                              AssignCommand(oTarget, ClearAllActions(TRUE));
                              ChangeFaction(oTarget, GetObjectByTag("coa_indepadvent_ftemplate"));
                              ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, RoundsToSeconds(nDuration));
                              DelayCommand(RoundsToSeconds(nDuration), ChangeFaction(oTarget, oOriginalFaction));
                          }
      
                          // Visual effect on charm success
                          ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
                      }
                  }
              }
          }
      }
      

      Puffy's bumbling Scum-goblin minion.

      Mr.MolochM 1 Reply Last reply Reply Quote
      • Mr.MolochM
        Mr.Moloch @SpiffyMeister
        last edited by

        @SpiffyMeister said in Charm Person Duration is wrong.:

        NW_S0_CharmPer

        Call me crazy, but this is doing the same thing.

        //---ADDED BY FARGLE 11/26/19---
            //With GSF Enchantment, duration should be turn/lvl
            //With SF Enchantment, duration should be 3 rounds/lvl
            if(bHasGSFEn == TRUE) {
                nDuration = nCasterLevel * 10;
            } else if(bHasSFEn = TRUE) {
                nDuration = nCasterLevel * 3;
            }
        

        In the future, there are two simple rules to remember:

        NO SPITTING.

        DO NOT CROSS MISTER MOLOCH.

        https://youtu.be/dQw4w9WgXcQ?si=uHdfqTMS7FMTWREf

        1 Reply Last reply Reply Quote
        • Mr.MolochM Mr.Moloch moved this topic from Bug Reports on
        • 1 / 1
        • First post
          Last post