Aller au contenu

Photo

SetEffectInteger problems?


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

#1
stoffe -mkb-

stoffe -mkb-
  • Members
  • 3 messages
I am having problems getting the SetEffectInteger() function to work properly. It seems like the values I set on an effect never get stored, and I can't figure out why. This applies to both storing the integer value at a new index, and inserting a new value at one that already has a value set (in which case it just keeps the old value).

I made a simple test script (run from the console) to try it out. Does anyone have any idea why this script always results in the output:

The first value is 0
The second value is 0
The third value is 0
The fourth value is 0

...when the script is run?

The script:

void ST_Debug(string sMsg, int bPrintToLog=FALSE) {
    DisplayFloatyMessage(GetMainControlled(), sMsg, FLOATY_MESSAGE, 16777215, 10.0);

    if (bPrintToLog)
        PrintToLog(">>>>>>>>>> ST DEBUG:" + sMsg);
}

void main()
{
    int nVal = 0;

    // ---------------------------------------------------------
    effect eTest = Effect(EFFECT_TYPE_TEST);
   
    SetEffectInteger(eTest, 0, 10);
    nVal = GetEffectInteger(eTest, 0);
    ST_Debug("The first value is " + ToString(nVal));

    SetEffectInteger(eTest, 10, 20);
    nVal = GetEffectInteger(eTest, 10);
    ST_Debug("The second value is " + ToString(nVal));

    // ---------------------------------------------------------
    effect eTest2 = EffectStun();
   
    SetEffectInteger(eTest2, 0, 30);
    nVal = GetEffectInteger(eTest2, 0);
    ST_Debug("The third value is " + ToString(nVal));

    SetEffectInteger(eTest2, 10, 40);
    nVal = GetEffectInteger(eTest2, 10);
    ST_Debug("The fourth value is " + ToString(nVal));
}

Modifié par stoffe -mkb-, 27 août 2010 - 02:19 .


#2
TimelordDC

TimelordDC
  • Members
  • 923 messages
SetEffectInteger returns an effect so you will have to assign it explicitly.

Example: eTest = SetEffectInteger(eTest, 0, 10);

#3
FergusM

FergusM
  • Members
  • 460 messages
SetEffectInteger does not change your existing effect. It returns a new effect.

So you want to use it like this:

effect eTest = blah;
eTest = SetEffectInteger(eTest,0,10);

Common mistake, I made it too. :) The same applies for SetEvent... functions as well.

If you right click on SetEffectInteger and select 'go to definition', you can see in the window that pops up that the return value is the modified effect.

EDIT: Ahh, beaten. :)

Modifié par FergusM, 27 août 2010 - 04:05 .


#4
stoffe -mkb-

stoffe -mkb-
  • Members
  • 3 messages

TimelordDC & FergusM wrote...

SetEffectInteger returns an effect so you will have to assign it explicitly.

Example: eTest = SetEffectInteger(eTest, 0, 10);


Doh, that's a silly mistake. Thanks :)

But since you get a copy of the effect in return from the SetEffectInteger() function, would this make it impossible to change the value of an effect integer on an effect that has already been applied to a creature? I can retrieve the applied effect (a Shapechange effect in this particular case) off the creature with GetEffects(), but how would I stick the effect with the added integer value back onto the creature without re-applying the effect? 

Modifié par stoffe -mkb-, 27 août 2010 - 08:13 .


#5
TimelordDC

TimelordDC
  • Members
  • 923 messages
My guess is you will have to re-apply the effect.

In that case, the effect will exist in parallel with the previous effect so you will have to take that into account if you are changing any time-related parameters.