branch options

jonsilva

New member
hello

is it possible to use some kind of branch command when a level ends
to go to a specific chossen level...?
i wanted to avoid creating and spawning a branch .txt file...
and maybe use a command "branch lvl**" in the level.txt where the enemies and obstacles are spwaned... to go to another place

i found this command "skiptoset" but i dont know it works
 
Bloodbane said:
It sounds like dirU entity is not working well so we might need to see dirU text
However, why don't you make a similar entity like dirU which uses jumptobranch function? something like dir
Then instead of setting level like that why don't you set it like this:

(levels.txt code)

Use that dir to replace exit2 and set its alias to Field0

Well, here's the code for dirU:
name dirU
health  50
type    endlevel
shadow 0
nolife  1
falldie 1
nodieblink 1
antigravity 100
nomove 1
setlayer 1
facing 1
offscreenkill 10000

anim spawn
delay 1
offset  18  16
bbox  8  7  20  19
frame data/chars/misc/markers/dir/dirU.png

anim idle
offset  18  16
bbox  8  7  20  19
frame data/chars/misc/markers/dir/dirU.png

anim pain
@script
    void self = getlocalvar("self");
    char Name = getentityproperty(self,"name");

    if(frame==1){
  jumptobranch(Name, 1);
    }
@end_script
delay 5
offset  18  16
frame data/chars/misc/markers/dir/dirU.png

anim death
delay 1
offset  18  16
frame data/chars/misc/markers/dir/dirU.png

But... earlier in this very thread, didn't you say that having two or more entities like this in a single level won't work? Here: http://www.chronocrash.com/forum/index.php?topic=1627.msg20075#msg20075
 
I think there's misunderstanding here. What I meant there is you can't modify endlevel typed entities with that script

And that's the reason why your dirU doesn't work the way you want to. It works like endlevel entity which simply ends current level if touched regardless of any script it has

So if you want flexible exit entity which can be set manually in level text, don't use endlevel type at all

Okay, why don't you use this one instead:

name Exit
type none
antigravity    100
setlayer 100
offscreenkill 3000


anim idle # arrow pointing right
@script
    void self = getlocalvar("self");
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");
    void P3 = getplayerproperty(2, "entity");
    void P4 = getplayerproperty(3, "entity");

    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    char Name = getentityproperty(self,"name");
    float Tx1 = getentityproperty(P1, "x");
    float Tz1 = getentityproperty(P1, "z");
    float Tx2 = getentityproperty(P2, "x");
    float Tz2 = getentityproperty(P2, "z");
    float Tx3 = getentityproperty(P3, "x");
    float Tz3 = getentityproperty(P3, "z");
    float Tx4 = getentityproperty(P4, "x");
    float Tz4 = getentityproperty(P4, "z");

    float Disx1 = Tx1 - x;
    float Disz1 = Tz1 - z;
    float Disx2 = Tx2 - x;
    float Disz2 = Tz2 - z;
    float Disx3 = Tx3 - x;
    float Disz3 = Tz3 - z;
    float Disx4 = Tx4 - x;
    float Disz4 = Tz4 - z;

    if(Disz1 < 0){
      Disz1 = -Disz1;
    }

    if(Disz2 < 0){
      Disz2 = -Disz2;
    }

    if(Disz3 < 0){
      Disz3 = -Disz3;
    }

    if(Disz4 < 0){
      Disz4 = -Disz4;
    }

    if(frame == 1){
      if(Disx1 >= -20 && Disx1 <= 20 && Disz1 <= 10){
        jumptobranch(Name, 1);
      } else if(Disx2 >= -20 && Disx2 <= 20 && Disz2 <= 10){
        jumptobranch(Name, 1);
      } else if(Disx3 >= -20 && Disx3 <= 20 && Disz3 <= 10){
        jumptobranch(Name, 1);
      } else if(Disx4 >= -20 && Disx4 <= 20 && Disz4 <= 10){
        jumptobranch(Name, 1);
      }
    }
@end_script
loop 1
delay 5
offset 18 16
frame data/chars/misc/markers/dir/dirR.png
frame data/chars/misc/markers/dir/dirR.png

anim follow1 # arrow pointing up
@script
    void self = getlocalvar("self");
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");
    void P3 = getplayerproperty(2, "entity");
    void P4 = getplayerproperty(3, "entity");

    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    char Name = getentityproperty(self,"name");
    float Tx1 = getentityproperty(P1, "x");
    float Tz1 = getentityproperty(P1, "z");
    float Tx2 = getentityproperty(P2, "x");
    float Tz2 = getentityproperty(P2, "z");
    float Tx3 = getentityproperty(P3, "x");
    float Tz3 = getentityproperty(P3, "z");
    float Tx4 = getentityproperty(P4, "x");
    float Tz4 = getentityproperty(P4, "z");

    float Disx1 = Tx1 - x;
    float Disz1 = Tz1 - z;
    float Disx2 = Tx2 - x;
    float Disz2 = Tz2 - z;
    float Disx3 = Tx3 - x;
    float Disz3 = Tz3 - z;
    float Disx4 = Tx4 - x;
    float Disz4 = Tz4 - z;

    if(Disz1 < 0){
      Disz1 = -Disz1;
    }

    if(Disz2 < 0){
      Disz2 = -Disz2;
    }

    if(Disz3 < 0){
      Disz3 = -Disz3;
    }

    if(Disz4 < 0){
      Disz4 = -Disz4;
    }

    if(frame == 1){
      if(Disx1 >= -20 && Disx1 <= 20 && Disz1 <= 10){
        jumptobranch(Name, 1);
      } else if(Disx2 >= -20 && Disx2 <= 20 && Disz2 <= 10){
        jumptobranch(Name, 1);
      } else if(Disx3 >= -20 && Disx3 <= 20 && Disz3 <= 10){
        jumptobranch(Name, 1);
      } else if(Disx4 >= -20 && Disx4 <= 20 && Disz4 <= 10){
        jumptobranch(Name, 1);
      }
    }
@end_script
loop 1
delay 5
offset 18 16
frame data/chars/misc/markers/dir/dirU.png
frame data/chars/misc/markers/dir/dirU.png

anim follow2 # arrow pointing down
@script
    void self = getlocalvar("self");
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");
    void P3 = getplayerproperty(2, "entity");
    void P4 = getplayerproperty(3, "entity");

    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    char Name = getentityproperty(self,"name");
    float Tx1 = getentityproperty(P1, "x");
    float Tz1 = getentityproperty(P1, "z");
    float Tx2 = getentityproperty(P2, "x");
    float Tz2 = getentityproperty(P2, "z");
    float Tx3 = getentityproperty(P3, "x");
    float Tz3 = getentityproperty(P3, "z");
    float Tx4 = getentityproperty(P4, "x");
    float Tz4 = getentityproperty(P4, "z");

    float Disx1 = Tx1 - x;
    float Disz1 = Tz1 - z;
    float Disx2 = Tx2 - x;
    float Disz2 = Tz2 - z;
    float Disx3 = Tx3 - x;
    float Disz3 = Tz3 - z;
    float Disx4 = Tx4 - x;
    float Disz4 = Tz4 - z;

    if(Disz1 < 0){
      Disz1 = -Disz1;
    }

    if(Disz2 < 0){
      Disz2 = -Disz2;
    }

    if(Disz3 < 0){
      Disz3 = -Disz3;
    }

    if(Disz4 < 0){
      Disz4 = -Disz4;
    }

    if(frame == 1){
      if(Disx1 >= -20 && Disx1 <= 20 && Disz1 <= 10){
        jumptobranch(Name, 1);
      } else if(Disx2 >= -20 && Disx2 <= 20 && Disz2 <= 10){
        jumptobranch(Name, 1);
      } else if(Disx3 >= -20 && Disx3 <= 20 && Disz3 <= 10){
        jumptobranch(Name, 1);
      } else if(Disx4 >= -20 && Disx4 <= 20 && Disz4 <= 10){
        jumptobranch(Name, 1);
      }
    }
@end_script
loop 1
delay 5
offset 18 16
frame data/chars/misc/markers/dir/dirD.png
frame data/chars/misc/markers/dir/dirD.png

This exit entity is type none so it won't have problem like endlevel has. By default this exit entity shows arrow pointing right
If you want it to show arrow up, declare it like this:

spawn Exit
@script
void main()
{
    void self = getlocalvar("self");

    changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
}
@end_script
  alias  woods1b
  coords  271 966
  at  0

I made that with assumption that you have dirR.png and dirD.png :). If you don't have them.... well, why don't you make them? :)
 
Alright i need help with this stuff.

I have this map in TMNT Rescue-Palooza:

rescue_palooza_map2.png


Each blue bubble is a level, once you complete the level and go back to the map, that particuar bubble should not reappear.

Now, I have studied the Moonstone mod to death and for some reason what works in that mod is not working on mine. Maybe I am missing something?
- I have two maps, the one at the start of the game clears global variables. The second map is loaded after each level and does not modify variables at all.
- I created the "clear" entity that in theory sets the globalvar of that particular stage to 1, indicating that the level has been completed.
- I have that entity appear inside a level
- Each blue bubble in the map has script in their spawn animations indicating that if the level has been completed it should destroy itself.

All of this I lifted from Moonstone. It works perfectly well there but doesn't in my mod. WHYYYYY. I am using the same engine on both mods so that cannot be the issue.

Ideas?
 
If you're using newer builds, you don't need to set script in SPAWN animation like this
Level spawn script like this is enough to remove entity when certain global variable is set:

spawn marker
@script
void main()
{
    void self = getlocalvar("self"); //Get calling entity
    void Status1 = getglobalvar("Stage1");

    if(Status1 == 1){
      killentity(self);
    }
}
@end_script
alias Stage1
map 4
coords 200 400 1
at 0

This script has nothing to do with marker entity allowing it to be used by any entity
I can't guess the cause of your bug so my only suggestion is to use newer build and use that script above
 
Bloodbane said:
If you're using newer builds, you don't need to set script in SPAWN animation like this
Level spawn script like this is enough to remove entity when certain global variable is set:

spawn marker
@script
void main()
{
    void self = getlocalvar("self"); //Get calling entity
    void Status1 = getglobalvar("Stage1");

    if(Status1 == 1){
      killentity(self);
    }
}
@end_script
alias Stage1
map 4
coords 200 400 1
at 0

This script has nothing to do with marker entity allowing it to be used by any entity
I can't guess the cause of your bug so my only suggestion is to use newer build and use that script above

Thanks Blood. I'll try this first.
 
IT would be helpful if you would post whats inside of txt files and what exactly "doesnt work", whats happening ? Bubble reappear, maybe you forgot something in bubble or clearing variables in both maps or clearing them in stage ?
 
Back
Top Bottom