Flickering entites

O Ilusionista

Captain 100K
I don't want to derail the conversation, but SortID can be tricky before you get used to it. Can you describe what you did and maybe I can help.

DC
To not derail the original topic, let me open a new topic @DCurrent .

As I was explaining, I have an issue when using many entities on the same z position, as they start to flick.
Take a look on the video below. As far as I can notice, they start to flick once they get hit:

If I am not mistaken, you made this sortID script to me (bundled in the same script that turn boxes into enemies), as a spawnscript():

C-like:
void main()
{
void self = getlocalvar("self");
changeentityproperty(self, "type", openborconstant("TYPE_ENEMY"));
changeentityproperty(self, "velocity", 0, 0, 0);
changeentityproperty(self, "speed", 0);


int i;
    for (i = 0; i < openborvariant("count_entities"); ++i)
    {
                // If we on an odd box, don't do anything.
                if(i % 2)
                {
                     continue;
                }


        void ent = getentity(i);
        char name = getentityproperty(ent,"defaultname");
        if ( getentityproperty(ent, "exists") && (name == "box"))
           {
            int sort = getentityproperty(ent,"sortid");
            sort++;
            changeentityproperty(ent,"sortid", sort);
            changeentityproperty(ent,"setlayer",sort);
        }
}
}

The stage code, if it helps:
music data/music/sentinel_4.ogg

background data/bgs/porto/pceu.gif
water data/bgs/porto/pagua2.gif 3
bglayer data/bgs/porto/porto-shadow.gif 1 0 0 0 0 0 -1 1 1 5 0 0 0 0 0
panel data/bgs/porto/porto-final-new2.gif


type 1 0 1
direction both
settime 30
notime 0


order a

spawn1 0 20 120
spawn2 0 20 160
spawn3 0 60 120
spawn4 0 60 160

light 35 60
at 0

shadowcolor 1
at 0

shadowalpha 6
at 0

spawn hudItem
coords 240 260
at 0

#-------1

spawn empty
@script
void main()
{
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");

void stageType;
setglobalvar("stageType","bonus");

if(P1){
changeopenborvariant("nojoin", 1);
changeentityproperty(P1, "position", 50,160, 0);
changeentityproperty(P1, "direction", 1); //Face right
changeentityproperty(P1, "animation", openborconstant("ANI_GET"));
}
if(P2){
changeentityproperty(P2, "position", 450,160, 0);
changeentityproperty(P2, "direction", 0); //Face left
changeentityproperty(P2, "animation", openborconstant("ANI_GET"));
}
//changeopenborvariant("gfx_y_offset_adj", -20);
//changeopenborvariant("ypos", 0);
}
@end_script
coords 180 189
at 0

#----------------

spawn textControl
@script void main() {
performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW11"));
} @end_script
coords 240 200 90
flip 1
at 0

#FAKE Miss
spawn afake
@script void main() {
performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW21"));
} @end_script
coords 498 110
at 0

group 1 39
at 0

#------caixas
spawn box
spawnscript data/scripts/enemy.c
coords 150 120
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 185 120
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 220 120
health 120
2phealth 180
item money
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 255 120
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 290 120
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 325 120
health 120
2phealth 180
item money
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 360 120
health 120
2phealth 180
at 0
#--------

#------caixas up
spawn box
spawnscript data/scripts/enemy.c
coords 165 121 56
health 120
2phealth 180
item avid
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 200 121 56
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 235 121 56
health 120
2phealth 180
item money
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 270 121 56
health 120
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 305 121 56
health 120
2phealth 180
item money
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 340 121 56
health 120
2phealth 180
at 0

#--------

#------caixas
spawn box
spawnscript data/scripts/enemy.c
coords 150 140
health 120
2phealth 180
item money
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 185 140
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 220 140
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 255 140
health 120
2phealth 180
item iMP
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 290 140
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 325 140
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 360 140
health 120
2phealth 180
item money
at 0
#--------

#------caixas up
spawn box
spawnscript data/scripts/enemy.c
coords 165 141 56
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 200 141 56
health 120
2phealth 180
item money
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 235 141 56
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 270 141 56
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 305 141 56
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 340 141 56
health 120
2phealth 180
at 0

#--------

#------caixas
spawn box
spawnscript data/scripts/enemy.c
coords 150 160
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 185 160
health 120
2phealth 180
item money
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 220 160
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 255 160
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 290 160
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 325 160
health 120
2phealth 180
item coin
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 360 160
health 120
2phealth 180
item coin
at 0
#--------

#------caixas up
spawn box
spawnscript data/scripts/enemy.c
coords 165 161 56
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 200 161 56
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 235 161 56
health 120
2phealth 180
item money
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 270 161 56
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 305 161 56
health 120
2phealth 180
at 0

spawn box
spawnscript data/scripts/enemy.c
coords 340 161 56
health 120
2phealth 180
item money
at 0

#--------

group 1 1
at 0

spawn delay
health 20
coords 160 200
at 0

spawn textControl
@script void main() {
performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW13"));
} @end_script
coords 240 200 90
flip 1
at 0
I am using build 6315/6330. Should I move this code to a ondrawscript?

Any help is appreciated
 
To not derail the original topic, let me open a new topic @DCurrent .

As I was explaining, I have an issue when using many entities on the same z position, as they start to flick.
Take a look on the video below. As far as I can notice, they start to flick once they get hit:

If I am not mistaken, you made this sortID script to me (bundled in the same script that turn boxes into enemies), as a spawnscript():

C-like:
void main()
{
void self = getlocalvar("self");
changeentityproperty(self, "type", openborconstant("TYPE_ENEMY"));
changeentityproperty(self, "velocity", 0, 0, 0);
changeentityproperty(self, "speed", 0);


int i;
    for (i = 0; i < openborvariant("count_entities"); ++i)
    {
                // If we on an odd box, don't do anything.
                if(i % 2)
                {
                     continue;
                }


        void ent = getentity(i);
        char name = getentityproperty(ent,"defaultname");
        if ( getentityproperty(ent, "exists") && (name == "box"))
           {
            int sort = getentityproperty(ent,"sortid");
            sort++;
            changeentityproperty(ent,"sortid", sort);
            changeentityproperty(ent,"setlayer",sort);
        }
}
}

The stage code, if it helps:

I am using build 6315/6330. Should I move this code to a ondrawscript?

Any help is appreciated

Everything in the code looks OK at first glance. I must be missing something. I'll take deeper dive on my end and see what I can come up with.

DC
 
@DCurrent remember this bug? @Kratus is helping me fixing some issues and this really looks to be an engine bug - and you know that I am not the type of person who yeels this for every issue :)

I will translate what Kratus told me:
I found the solution by accident.
I was using drawstring inside the ondrawscript to show the "sortid" of each box on the screen to confirm if they were in the right order, then I realized that when the drawstring is activated the problem did not happen. So I left it enabled by writing the value of its own sortid far away from the visible area on the screen.

But there was still a second problem, if I exited the level and started again, sometimes the "sortid" order messed up so I saw that the previous script was not sorting correctly. After creating a new script to order the sortid during spawn this problem was solved.

I would need to look deeper into the source code to better understand this sortid issue, but from what I saw it acts with more emphasis when two or more entities have some kind of link and need a definition of which one will have priority on the Z axis, standing one in front of the other.

There are quite a few lines of code in the engine with assorted spawn, bind, parent and grab functions.

Apparently, the drawstring if used inside the ondraw ends up "forcing" the application of the correct sortid (or setlayer). And it needs to have something written, I tested using empty space instead of letters but it doesn't work.

The fix in action:
 
Back
Top Bottom