Globalvar not persistent?

O Ilusionista

Captain 100K
Guys, I am having a strange issue with globalvar and I need help.
As far as I remember, globalvars ARE persistent, right?

But I am facing a stranger behaviour: the globalvar get nullified out of the blue and I don't know WHY.


Let me explain how it works:

Emma Frost uses a "attack8" box, to trigger PAIN8.


At PAIN8 animation (triggers the MindControl)
Code:
@script
    if(frame==1){
      void self = getlocalvar("self");
      int MindControl = getglobalvar("MindControl");
      if (MindControl==NULL()) {
      changeentityproperty(self, "hostile", "TYPE_ENEMY");
      changeentityproperty(self, "type", openborconstant("TYPE_NPC"));
      changeentityproperty(self, "candamage", "TYPE_ENEMY");
      setglobalvar("MindControl", 1);
      spawner("dizzyfx", 0, 55, 1);
       }
    }
@end_script

Works fine. It will only trigger the MindControl if there is no other enemy being controlled (or I could control the entire game).

At IDLE animation (checks if MindControl is still active, if not, change to Follow 10)
Code:
@script
    void self = getlocalvar("self");
    int MindControl = getglobalvar("MindControl");
    int Type = getentityproperty(self, "type");

    if(frame==1 && MindControl==NULL() && Type==openborconstant("TYPE_NPC")){
      performattack(self,openborconstant("ANI_FOLLOW10"));
    }
@end_script

The code above checks if the the globalvar was nullified and it the enemy is now an NPC.
It woks fine and change the enemy to FOLLOW10 if not


At FOLLOW10 animation (disable MindControl)
Code:
@script
    if(frame==1){
      void self = getlocalvar("self");
      changeentityproperty(self, "hostile", "TYPE_PLAYER");
      changeentityproperty(self, "type", openborconstant("TYPE_ENEMY"));
      changeentityproperty(self, "candamage", "TYPE_PLAYER");
      setglobalvar("MindControl", NULL());
    }
@end_script




At dizzyfx header

name dizzyfx
type none
shadow 0
Antigravity 100


palette none

script @script

void main()
{

void self = getlocalvar("self");
void parent = getentityproperty(self, "parent");
int MindControl = getglobalvar("MindControl");

    if(parent!=NULL()){
    float x = getentityproperty(parent, "x");
    float z = getentityproperty(parent, "z");
    float a = getentityproperty(parent, "a");
    changeentityproperty(self, "position", x, z+1, a+55);
    }

    if (MindControl==NULL())
    { killentity(self);
    }
}
@end_script

And its IDLE
anim idle
loop
1
delay
4
offset
20 11
frame
data/chars/misc/dizzyfx/1.gif
frame
data/chars/misc/dizzyfx/2.gif
frame
data/chars/misc/dizzyfx/3.gif
frame
data/chars/misc/dizzyfx/4.gif
frame
data/chars/misc/dizzyfx/1.gif
frame
data/chars/misc/dizzyfx/2.gif
frame
data/chars/misc/dizzyfx/3.gif
frame
data/chars/misc/dizzyfx/4.gif

But someway the globalvar gets nullified out of the blue. I have a debug function to track its value and I can confirm when it got nullified.
Plus, the dizzyfx is not lasting until the global var is nullified.

What I am doing wrong? or its a bug?
 
follow10/idle anim animationscript you posted  is of Emma Frost or dizzyfx?
check well the parallel processes.
Try to comment the setglobalvar("MindControl", NULL()); to understand.
 
Pain8 and follow10 are enemy animation.
I had commented that line (but it won't affect anything since the enemy only goes to follow10 if the var was already nullified.

Even if I comment, the variable still gets nullified after some time
 
O Ilusionista said:
Pain8 and follow10 are enemy animation.
I had commented that line (but it won't affect anything since the enemy only goes to follow10 if the var was already nullified.

Even if I comment, the variable still gets nullified after some time

You forgot some setglobalvar("MindControl", NULL());  or clearglobalvars() or any for sure.
 
I double checked it. There is not such thing.

To make it easier, I renamed the variable only in this character to MindControl2.
It works and it don't get reset...untill Emma dies.

But Emma uses a ondeathscript which sets MindControl (with no 2 on its name ) to null. After she respawn, 2 seconds after it and the global variable.

Its so.strange
 
O Ilusionista said:
It works and it don't get reset...untill Emma dies.
Its so.strange

sure you forgot domething that reset var.
I advice you to use app like TextCrawler Pro to search a line in your whole project.
 
Sort of. Sometimes, when the charcter is lying down, but sometimes while he is walking. It happens just after a long time like 20 seconds or more. I had a script to nullify it once the character rises, but I removed it.
 
Back
Top Bottom