Solved endlevel item

Question that is answered or resolved.

Gurtag

Member
hey guys.. again seeking wisdom. been using endlevel item to finish some levels.. but now i found it presents some limitations and wanted to consult ways to overcome them, the things is i am trying to make the endlevel item floating but the endlevel functionality doesnt work with antigravity, it also hates itembox so.. i was thinking in using an enemy with an attack box and counterrange, puting an script or end level comand in the follow anim, but can find anything for that purpose...
 
hey guys.. again seeking wisdom. been using endlevel item to finish some levels.. but now i found it presents some limitations and wanted to consult ways to overcome them, the things is i am trying to make the endlevel item floating but the endlevel functionality doesnt work with antigravity, it also hates itembox so.. i was thinking in using an enemy with an attack box and counterrange, puting an script or end level comand in the follow anim, but can find anything for that purpose...

End level items are another one of those hacky things that were introduced to try and add control logic before we had script. They work, but don't handle any edge cases and that's why I generally advise ignoring them completely. The scripted branch commands are much more stable and you can attach them to whatever event you feel like. That's how I would do it.

DC
 
End level items are another one of those hacky things that were introduced to try and add control logic before we had script. They work, but don't handle any edge cases and that's why I generally advise ignoring them completely. The scripted branch commands are much more stable and you can attach them to whatever event you feel like. That's how I would do it.

DC
i use branch for some endlevel items and stages just dont know hot to triger an endlevel event(terminate the level on demand).. i could try a way to wipe out all enemies on screen bu that would result in further complications in most scenarios.

got it, thanks a lot damon.
 
Last edited:
If you want to end level by touching end of screen or level, I suggest using something like this:
Code:
name        Exit
type        none
antigravity     100
offscreenkill    4000
    

anim    idle # left/right exit
@script
    void self = getlocalvar("self");
    void P1 = getplayerproperty(0, "entity");

    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "y");
    float Dir = getentityproperty(self, "direction");
    char Name = getentityproperty(self,"name");
    float Tx1 = getentityproperty(P1, "x");
    float Ty1 = getentityproperty(P1, "y");

    float Disx1 = Tx1 - x;
    float Disy1 = Ty1 - y;

    if(frame >= 1){
      if(Disx1 >= -20 && Disx1 <= 20){
        int Health = getentityproperty(self,"health");
        int Rx, Ry;

        Rx = Health/1000;
        Ry = Health%1000;

        setglobalvar("x0", Rx);
        setglobalvar("y0", Ry+Disy1);
        setglobalvar("Dir0", Dir);
        jumptobranch(Name, 1);
      }
    }
@end_script
    loop    1
    delay    5
    offset    30 30
    frame    data/chars/misc/empty.png
    frame    data/chars/misc/empty.png
    frame    data/chars/misc/empty.png
    frame    data/chars/misc/empty.png
    frame    data/chars/misc/empty.png #

This is designed to work in metroidvania but with some adjustments, it could work in regular levels.
 
If you want to end level by touching end of screen or level, I suggest using something like this:
Code:
name        Exit
type        none
antigravity     100
offscreenkill    4000
   

anim    idle # left/right exit
@script
    void self = getlocalvar("self");
    void P1 = getplayerproperty(0, "entity");

    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "y");
    float Dir = getentityproperty(self, "direction");
    char Name = getentityproperty(self,"name");
    float Tx1 = getentityproperty(P1, "x");
    float Ty1 = getentityproperty(P1, "y");

    float Disx1 = Tx1 - x;
    float Disy1 = Ty1 - y;

    if(frame >= 1){
      if(Disx1 >= -20 && Disx1 <= 20){
        int Health = getentityproperty(self,"health");
        int Rx, Ry;

        Rx = Health/1000;
        Ry = Health%1000;

        setglobalvar("x0", Rx);
        setglobalvar("y0", Ry+Disy1);
        setglobalvar("Dir0", Dir);
        jumptobranch(Name, 1);
      }
    }
@end_script
    loop    1
    delay    5
    offset    30 30
    frame    data/chars/misc/empty.png
    frame    data/chars/misc/empty.png
    frame    data/chars/misc/empty.png
    frame    data/chars/misc/empty.png
    frame    data/chars/misc/empty.png #

This is designed to work in metroidvania but with some adjustments, it could work in regular levels.
thanks a lot man that would come handy
 
Back
Top Bottom