Author Topic: Dispel Non-hostile Effects on Self  (Read 611 times)

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Dispel Non-hostile Effects on Self
« Reply #15 on: August 07, 2015, 01:09:48 am »


               

Fwiw, I setup a quick test with the original script and it does as expected remove all the effects when run.



               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Dispel Non-hostile Effects on Self
« Reply #16 on: August 07, 2015, 01:41:08 am »


               


Fwiw, I setup a quick test with the original script and it does as expected remove all the effects when run.




 


An ingame test or a test similar to the long transcript you posted? I swear up and down that the code I wrote functions as intended for me and that I have not altered it since posting the original. Also, what does fwiw mean?


 


Squatting Monk's is probably the best to use.


 


EDIT: Here's the module I tested this in if anyone wants to take a peak and see if I'm missing something: https://www.dropbox....relith.mod?dl=0



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Dispel Non-hostile Effects on Self
« Reply #17 on: August 07, 2015, 02:11:27 am »


               

I was not doubting that you were seeing what you were seeing, just that the script was not doing that so something else must be happening.


 


I see what's going on. You are applying the EffectDazed with DURATION_TYPE_INSTANT. There seems to be an engine bug when you do that.  The effect it not removable at all.  Resting does not clear it either.


 


You are not supposed to use INSTANT for this type of effect only TEMPORARY or PERMANENT.


 


Others may be able to comment on whether that bug is known or not.  The Lexicon says " This effect cannot be applied instantly, only temporarily or permanently." But that does not seem to be accurate since the effect is clearly applied. Maybe we need different wording there. 


 


Edit : That listing was the actual code the script compiles to... the byte code read by the machine that executes scripts in the engine, not a log or transcipt of a test execution, but it shows the exact steps the execution of the script would entail.


 


fwiw means "for what it's worth" '<img'>



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Dispel Non-hostile Effects on Self
« Reply #18 on: August 07, 2015, 02:54:26 am »


               

Ah, this makes more sense now. That same wording is present in the Lexicon pages of most of the other effect constructor functions (all the ones that would be expected to have a duration, however short). I wonder if these other effects show this same behavior when applied with DURATION_TYPE_INSTANT. If so, then it's not a bug, per se, but just unintended results.


 


Edit: looking through the Omnibus, it looks like this was a known bug. Before SupernaturalEffect() was added, people were using it to force effects to stay present through rests.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Dispel Non-hostile Effects on Self
« Reply #19 on: August 07, 2015, 03:10:33 am »


               

Thanks Monk.  I had not gone digging in there yet.  One person's "unintended result" is another person's bug '<img'>



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Dispel Non-hostile Effects on Self
« Reply #20 on: August 07, 2015, 03:18:59 am »


               

True. I'll update the language for those pages and see about adding a caveat somewhere about using instant duration.



               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Dispel Non-hostile Effects on Self
« Reply #21 on: August 07, 2015, 09:14:13 am »


               

Sweet, mystery solved and I learned a bunch along the way. Thanks guys '<img'>



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Dispel Non-hostile Effects on Self
« Reply #22 on: August 09, 2015, 06:27:18 am »


               


Here's an alternate way of doing this:



void RemoveNonHostileSpellEffects(object oTarget)
{
    int nSpellID;
    effect eEff = GetFirstEffect(oTarget);
    while (GetIsEffectValid(eEff))
    {
        nSpellID = GetEffectSpellId(eEff);
        if (!StringToInt(Get2DAString("spells", "HostileSetting", nSpellID)))
            RemoveEffect(oTarget, eEff);
       
        eEff = GetNextEffect(oTarget);
    }
}

  • will not remove effects not applied by spell

 




 


Not sure on that point.  Non-spells would not have an ID, and thus their strings from indexing would likely be null and thus be treated the same as a 0 in "HostileSetting"


               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Dispel Non-hostile Effects on Self
« Reply #23 on: August 09, 2015, 08:07:07 pm »


               

Good catch! I'd originally written this to remove hostile spell effects and just added the ! thinking that would do it. Since Get2daString() returns "" if the lookup fails, we can just check if the string matches "0".



void RemoveNonHostileSpellEffects(object oTarget)
{
    effect eEff = GetFirstEffect(oTarget);
    while (GetIsEffectValid(eEff))
    {
        if (Get2DAString("spells", "HostileSetting", GetEffectSpellId(eEff)) == "0")
            RemoveEffect(oTarget, eEff);
       
        eEff = GetNextEffect(oTarget);
    }
}