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?
Difficulty removing an effect.
Débuté par
M. Rieder
, févr. 20 2011 09:20
#1
Posté 20 février 2011 - 09:20
#2
Posté 20 février 2011 - 09:49
I suspect you'll need a GetNextEffect() function in that 'while' loop to remove both effects.
#3
Posté 21 février 2011 - 12:45
Ah yes, humble pie, my favorite! Thanks for catching my careless mistake.
#4
Posté 21 février 2011 - 03:12
need to getfirst effect whenever you find one, or you will skip some.
#5
Posté 23 février 2011 - 04:19
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
Posté 23 février 2011 - 04:38
// 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
Posté 23 février 2011 - 04:39
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
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
Posté 23 février 2011 - 12:33
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.
The script is an unequip script for an item. I really appreciate the response.
#9
Posté 24 février 2011 - 11:42
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 )
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
Posté 25 février 2011 - 12:16
I need to go back and change several scripts now. I really appreciate the information.





Retour en haut






