Aller au contenu

Photo

Difficulty removing an effect.


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Here's the script:

________________________-

void main()
{
object oTarget = GetPCItemLastUnequippedBy();
effect eEffect = GetFirstEffect(oTarget);
int nEffectType;
while (GetIsEffectValid(eEffect))
 {
 nEffectType = GetEffectType(eEffect);
 if((nEffectType == 74)||
  (nEffectType == 36))
  {
  RemoveEffect(oTarget,eEffect);
  }
 }
 
}

__________________________________________


It's a tag-based script that fires when the item is unequipped.  The haste effect (nEffectType = 36) is always removed.  I can only make the visual effect (nEffectType = 74) remove when  oTarget is defined as GetFirstPC().  And then it only works if you right click and unequip using the GUI.  It won't work if you double left click or click and drag. 

Pretty wierd stuff.  Any suggestions?

#2
Dann-J

Dann-J
  • Members
  • 3 161 messages
I suspect you'll need a GetNextEffect() function in that 'while' loop to remove both effects.

#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Ah yes, humble pie, my favorite! Thanks for catching my careless mistake.

#4
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
need to getfirst effect whenever you find one, or you will skip some.

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages

painofdungeoneternal wrote...

need to getfirst effect whenever you find one, or you will skip some.



I'm not following you here.  Are you talking about putting it somewhere else in the script?

#6
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
// outer test, is this worth doing at all
if( GetHasSpellEffect( iSpellId, oTarget ) )
{
	effect eEffect = GetFirstEffect(oTarget);
	while (GetIsEffectValid(eEffect))
	{
		if ( GetEffectSpellId(eEffect) == iSpellId )
		{
			//If the effect was created by the spell then remove it
			RemoveEffect(oTarget, eEffect);
			eEffect = GetFirstEffect(oTarget);  // 8/28/06 - BDF-OEI: start back at the beginning to ensure that linked effects are removed safely
		}
		else
		{
			//Get next effect on the target
			eEffect = GetNextEffect(oTarget);
		}
	}
}

Note the comment left by the obsidian developer.

your code i would do as follows
void main()
{
object oTarget = GetPCItemLastUnequippedBy();
effect eEffect = GetFirstEffect(oTarget);
while (GetIsEffectValid(eEffect))
{
if ( GetEffectType(eEffect) ==EFFECT_TYPE_VISUALEFFECT || GetEffectType(eEffect) == EFFECT_TYPE_HASTE )
{
RemoveEffect(oTarget, eEffect);
eEffect = GetFirstEffect(oTarget);
}
else
{
eEffect = GetNextEffect(oTarget);
}

}
}
[/code]

I have no idea what you are doing, it would be good for the overland map i imagine, as it would be removing quite a few visuals but those might end up affecting other things ( it would wreck havoc on my tracking effects ). I went ahead and put the proper constants in as well. But the only thing i wanted to point out is you should start over or you will occasionally skip a few of the effects.

Modifié par painofdungeoneternal, 23 février 2011 - 04:39 .


#7
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
I'm not sure what pain meant either but with, as Dan pointed out, the added GetNextEffect line, your script would look like so:

void main()
{
    object oTarget = GetPCItemLastUnequippedBy();
    effect eEffect = GetFirstEffect(oTarget);
    int nEffectType;
    while (GetIsEffectValid(eEffect))
    {
        nEffectType = GetEffectType(eEffect);
        if(nEffectType == 74 || nEffectType == 36)
        {
            RemoveEffect(oTarget, eEffect);
        }
        eEffect = GetNextEffect(oTarget);
    }
}

Sounds like you already figured it out but figured I'd post it just in case.

EDIT: Ahhh. Now I see what Pain was talking about

Modifié par GhostOfGod, 23 février 2011 - 05:02 .


#8
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Oooohhhhhhh! I think I get it now. You are saying that after I remove an effect, I should have the script start back with the first effect instead of moving on to the next effect so that no effects are missed. Is that correct?



The script is an unequip script for an item. I really appreciate the response.

#9
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
yep



a very simple thing, but one even the devs who point it out in their notes only do haphazardly. ( one of the first things i did was redo EVERY remove effect function the devs did so they all work the correct way in my CSL library )

#10
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I need to go back and change several scripts now. I really appreciate the information.