Aller au contenu

Photo

Catch current effects and reapply + new effects


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

#1
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
I am trying to catch all the current effects with a specific abilityID and reapply new effects on top of those effects but this time with a new abilityID attached to them.

What I do:

- Check if there is an effect with AbilityID = 1234
- use GetEffectsByAbilityId to create an array of all the effects with that same AbilityID and place them in eEffects
- use GetArraySize to get the last value nCount of the array
- in a for loop apply new effects to the array using eEffects[nCount + i]
- use RemoveStackingEffects to remove all effects with AbilityID = 1234
- Use a custom script ApplyEffectsOnObject (which works correctly) to apply an array of effects to the player
- Apply AbilityID + 1 (f.e. 1235) to these new effects

When I count the number of effects at the start of the script for the first time it counts the correct number, and at the end 3 new effects are applied (nCount has increased by 3)

However, after the script is called again, nCount again returns 2 effects instead of the new 5 and the script basically goes from 2 to 5 again every time the script is called.

I've rechecked everything 5 times already, used a lot of Floaty's and Logwrites to see where things go bad but I can't seem to find anything that can cause this...

At the end of the script it returns the correct amount of effects, yet when calling the script again it returns the wrong amount, but my script can't have anything to do with that as it doesn't do anything before the start Floaty and after the end Floaty?

I'm at a total loss here :crying: The only thing I can think of is that the format in which GetEffectByAbilityId returns the effect is different from the way I set the new effects:

effect[] eEffects    = GetEffectsByAbilityId(stEvent.oCaster, abilityID);
int nCount  = GetArraySize(eEffects);
for(i=0;i lt nMax;i++)
eEffects[nCount+i] = EffectModifyProperty(PROPERTY_ATTRIBUTE_DAMAGE_RESISTANCE_COLD,   -(RandomRange(0.1f, 5.0f) * iMultiply));

RemoveStackingEffects(stEvent.oCaster, stEvent.oCaster, abilityID);
ApplyEffectsOnObject(EFFECT_DURATION_TYPE_PERMANENT, eEffects, stEvent.oCaster, 0.0f, stEvent.oCaster, abilityID+1);


Modifié par Joshua Raven, 05 décembre 2009 - 02:52 .


#2
Georg Zoeller

Georg Zoeller
  • Members
  • 188 messages
applying and removing effects from inside effects is dangerous, it can very easily lead the script failing to run due to exceeding the maximum recursion level for scripts.






#3
TimelordDC

TimelordDC
  • Members
  • 923 messages
I haven't gone into scripting at a detailed level but from your code, there may be 2 areas which need looking into -



-> get all current effects for abilityID 1234 and store in array

-> extend array

-> remove stacking effects for abilityID 1234 => there wouldn't be stacking effects at this point, would they? (since the effects present are the original effects) I assume stacking effects mean same effect type.

-> apply effects from array with a different abilitID 1235.



Since the effects are not removed in the first place and the array is formed from the effects tied to the first abilityID, you will always get the same count. Correct?

#4
Joshua Raven

Joshua Raven
  • Members
  • 182 messages

there wouldn't be stacking effects at this point, would they? (since the effects present are the original effects) I assume stacking effects mean same effect type.


No, the removestackingeffects works in the script. Basically the script applies 10 effects for example and they all have the same AbilityID. By firing removestackingeffects and point it to that ID, it removes all the applied effects.

I tested this in the game, and it works.

Since the effects are not removed in the first place and the array is formed from the effects tied to the first abilityID, you will always get the same count. Correct?


As stated, the original effects are removed. And no, I don't believe the first effects are still tied to the first abilityID. Though that might be worth investigating. There is a function that changes the abilityID for an effect, but since I reapply all effects using abilityID+1 I figured that wouldn't be needed.

I actually believe I already tested this as well and they do update to the new abilityID, still, will look into this again, thanks for the tips.