• All, I am currently in the process of migrating domain registrations. During this time there may be some intermittent outages or slowdowns. Please contact staff if you have any questions.

[Tutorial] Custom Spawn/intro for stages

O Ilusionista

Captain 80K
Custom Spawn/intro for stages tutorial
By Bloodbane, modified by O Ilusionista*

* Explaining this tutorial:
I have no intention in stealing other people credits, at all. The version I did is a tad different from the Bloobane version but yes, he should be credited - when I found this code, I forgot who made it (back when I was just copy and past codes on my notepad without knowing who did them - now I simply forward the topic to me). It was a honest mistake, by no means I intended to steal something from Bloodbane , someone that inspires me.

I just had modified the code to fits my need - adding an specific animation to the spawn - and made the tutorial. The original code was made by Bloodbane.


Now the original text bellow:

I made modified this code years ago and saw that someone asked about something similar at my FB group. Basically, this code allows you to do a custom spawn for each stage - and that's how I do the intros in my game. The original was made by Bloodbane - ChronoCrash
Credits fixed ;)

You will need an entity to trigger this (it can be any entity, I use a wildcard entity called "empty") or use this as levelscript.
ah, just an extra tip I forgot to say - Your character NEEDS TO HAVE A SPAWN ANIMATION, or it won't work.

In the code below, I position the players (my game only has 2) where I want (-490,189, 0 - yeah, I spawn the player outside the screen), facing the side I want (direction) and the animation I want (FOLLOW60).

Tips
1- Do not use this code in updatescript, because it is triggered all the time. Levelscript is fired once when the scene is loaded

2- You can block another player from entering the game (as in my game),
Code:
changeopenborvariant("nojoin", 1);
but you need to enable it back, or if you die ... nor either you can return to the game.

3- Remember to increase the number of MAXFOLLOWS.

4- This code fires just one time, when the players spawns on the level. It won't affect any respawn animation.

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

if(P1){
changeentityproperty(P1, "position", -490,189, 0); // Set position
changeentityproperty(P1, "direction", 1); //Face right
changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW60"));
}
if(P2){
changeentityproperty(P2, "position", -490,189, 0);
changeentityproperty(P2, "direction", 1); //Face right
changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW60"));
}
}
@end_script
coords 180 189
at 0

######## Levelscript method

Just paste this in your level .txt

Code:
levelscript @script
void main()
{
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");

if(P1){
changeentityproperty(P1, "position", -490,189, 0);
changeentityproperty(P1, "direction", 1); //Face right
changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW60"));
}
if(P2){
changeentityproperty(P2, "position", -490,189, 0);
changeentityproperty(P2, "direction", 1); //Face right
changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW60"));
}
}
@end_script

Those intros adds some cool effect so give it a try :)

In this video you can see her in action - this is how I make Deadpool/Captain appear on screen.


Another example is the animation that Kitty Pryde performs when entering the screen (she comes running from off-screen, instead of using the normal Spawn animation)

 
Last edited:
Yes - put the code in the respawn animation.
See my game, in the aerial stage. The players always spawns outside the screen and moves toward it, in both spawn and respawn animations.
 
O Ilusionista said:
Yes - put the code in the respawn animation.
See my game, in the aerial stage. The players always spawns outside the screen and moves toward it, in both spawn and respawn animations.

Thanks my friend!
 
Sorry, but not work!

Here my anim respawn with the script:
Code:
anim respawn
@script
void stageName = getglobalvar("stageName");
if (stageName == "stage6-3"){
     setglobalvar("stageName","stage6-3");
     }

    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P2 = getplayerproperty(1, "entity");
    setglobalvar("clearCount", 1);

    if(P1){
      changeopenborvariant("nojoin", 1);
      changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW50"));
    }
    if(P2){
      changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW50"));
    }
    if(P3){
      changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW50"));
    }
}
@end_script
	loop	0
        delay	1
	offset	1 1
	frame	data/chars/caro/empty.png
        delay	9
	@cmd	spawnbind "pspawn" 0 0 1  0 0
	sound	data/sounds/respawn.wav
	frame	data/chars/caro/empty.png
	frame	data/chars/caro/empty.png
        delay	4
	offset	95 173
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
        delay	12
	frame	data/chars/caro/bfat00.png
	frame	data/chars/caro/select0.png


I followed the steps you explained here to identify the stage:
http://www.chronocrash.com/forum/index.php?topic=3903.msg53693#msg53693

My idea is to use your method to identify 2 stages, Stage6-3 and Stage8-1-3.
And when placing the script in the anim respawn, if it identifies one of the stage, it changes a specific animation depending on the stage.
 
Dante, when you need to report error or ask for help, you need to be more descriptive.
Simply writing "not work"...doens't work :)
What happens? A crash? An error report? Nothing?
Please, help me to help you, ok?

The first thing I can notice is that you aren't using my code properly.
As I've suggested you many times alreay, you need to learn to read the code to understand how it works.
If you just copy and paste, you won't go anywhere.

Take a look at what you did:
Code:
void stageName = getglobalvar("stageName");
if (stageName == "stage6-3"){
     setglobalvar("stageName","stage6-3");
     }

- You are getting the value of a global variable named "stageName"
- If  the stageName is "stage6-3", you are setting the same variable...to the same value?

It's like to check if an animal is a horse. If its a horse, then call it horse :)]

Now compare to what I wrote:
Code:
@script
void main()
{
     void stageName;
     if (!stageName){
     setglobalvar("stageName","My Stage"); // Put your stage name here. It's CASE SENSITIVE.
     }
}
@end_script
- declare a variable called stageName
- if that variable value is NULL, them set that variable as "My Stage".
 
Sincerely, I make my best effort my friend, but besides that I have a hard time understanding how the code works, sometimes I find it difficult to understand certain technical explanations in English, since I do not perfectly handle the language.

I did it back based on what I understood from your explanation, although it is not very clear to me how it works, how I can add two stages with a specific animation for each one.

Sorry if in my previous mistake I just said that it does not work, is that it gave me a lot of errors in the log and I assumed that I had done wrong.

Here my last try:
Code:
anim spawn
	loop	0
        delay	2
	offset	98 173
	frame	data/chars/caro/idle0.png

anim respawn
@script
     void stageName;
     if (!stageName){
     setglobalvar("stageName","stage6-3"); // Put your stage name here. It's CASE SENSITIVE.
     }

    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P2 = getplayerproperty(1, "entity");
    setglobalvar("clearCount", 1);

    if(P1){
      changeopenborvariant("nojoin", 1);
      changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW50"));
    }
    if(P2){
      changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW50"));
    }
    if(P3){
      changeentityproperty(P3, "animation", openborconstant("ANI_FOLLOW50"));
    }
}
@end_script
	loop	0
        delay	1
	offset	1 1
	frame	data/chars/caro/empty.png
        delay	9
	@cmd	spawnbind "pspawn" 0 0 1  0 0
	sound	data/sounds/respawn.wav
	frame	data/chars/caro/empty.png
	frame	data/chars/caro/empty.png
        delay	4
	offset	95 173
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
        delay	12
	frame	data/chars/caro/bfat00.png
	frame	data/chars/caro/select0.png

Here the log errors:
Code:
Script error: data/chars/caro/caro.txt, line 39: Invalid external declaration 'if' (in production 'external_decl')

    if(animhandle==198)
    ^



Script error: data/chars/caro/caro.txt, line 47: Invalid external declaration 'if' (in production 'external_decl')

     	if(frame == 1){
        ^



Script error: data/chars/caro/caro.txt, line 229: Invalid external declaration 'if' (in production 'external_decl')

if(frame == 14){
^



Script error: data/chars/caro/caro.txt, line 284: Invalid external declaration 'changeentityproperty' (in production 'external_decl')

    changeentityproperty(self, "velocity", 0, 0, 0);
    ^



Script error: data/chars/caro/caro.txt, line 460: Invalid external declaration 'if' (in production 'external_decl')

		if(frame==0){
        ^



Script error: data/chars/caro/caro.txt, line 463: Invalid external declaration 'changeentityproperty' (in production 'external_decl')

		  changeentityproperty(vSelf, "velocity", 0, 0 , 0); // This is to stop entity from moving forward
          ^



Script error: data/chars/caro/caro.txt, line 523: Invalid external declaration 'if' (in production 'external_decl')

      if(r > 0){
      ^



Script error: data/chars/caro/caro.txt, line 566: Invalid external declaration 'if' (in production 'external_decl')

   if ( frame == 0 && iMP < 25 )
   ^



Script error: data/chars/caro/caro.txt, line 709: Invalid external declaration 'if' (in production 'external_decl')

if(frame == 3){
^



Script error: data/chars/caro/caro.txt, line 802: Invalid external declaration 'if' (in production 'external_decl')

if(frame == 1){
^



Script error: data/chars/caro/caro.txt, line 1109: Invalid external declaration 'changeentityproperty' (in production 'external_decl')

	changeentityproperty(self, "velocity", 0,0,0);
    ^



Script error: data/chars/caro/caro.txt, line 1254: Invalid external declaration 'if' (in production 'external_decl')

   if ( frame == 0 && iMP < 25 )
   ^



Script error: data/chars/caro/caro.txt, line 1305: Invalid external declaration 'if' (in production 'external_decl')

   if ( frame == 0 && iMP < 80 )
   ^



Script error: data/chars/caro/caro.txt, line 1412: Invalid external declaration 'if' (in production 'external_decl')

if(frame == 11){
^



Script error: data/chars/caro/caro.txt, line 1773: Invalid external declaration 'if' (in production 'external_decl')

   if ( frame == 0 && iMP < 100 )
   ^



Script error: data/chars/caro/caro.txt, line 1791: Invalid external declaration 'if' (in production 'external_decl')

   if(frame==1){                                     //Enumerate and loop through entity collection.      
   ^



Script error: data/chars/caro/caro.txt, line 1799: Invalid external declaration 'changeentityproperty' (in production 'external_decl')

   changeentityproperty(vEntity, "frozen", 1);          
   ^



Script error: data/chars/caro/caro.txt, line 1809: Invalid external declaration 'if' (in production 'external_decl')

if(frame == 5){
^



Script error: data/chars/caro/caro.txt, line 1860: Invalid external declaration 'if' (in production 'external_decl')

      if(Hit=="Kill"){
      ^



Script error: data/chars/caro/caro.txt, line 1930: Invalid external declaration 'if' (in production 'external_decl')

      if(Hit=="Kill"){
      ^



Script error: data/chars/caro/caro.txt, line 1984: Invalid external declaration 'if' (in production 'external_decl')

      if(Hit=="Kill"){
      ^



Script error: data/chars/caro/caro.txt, line 2038: Invalid external declaration 'if' (in production 'external_decl')

      if(Hit=="Kill"){
      ^



Script error: data/chars/caro/caro.txt, line 2558: Invalid external declaration 'changeentityproperty' (in production 'external_decl')

    changeentityproperty(self, "velocity", 0, 0, 0);
    ^


Script compile error in 'CAROLINA': P3 line 29, column 7

********** An Error Occurred **********
*            Shutting Down            *

Can't compile script 'CAROLINA' data/chars/caro/caro.txt
Total Ram: 4294967295 Bytes
 Free Ram: 4294967295 Bytes
 Used Ram: 52826112 Bytes

Release level data...........
Done!

Release graphics data........	Done!
Release game data............


Release game data............	Done!
Release timer................	Done!
Release input hardware.......	Done!
Release sound system.........	Done!
Release FileCaching System...	Done!

**************** Done *****************

Can't compile script 'CAROLINA' data/chars/caro/caro.txt
 
Player 3 is not declared at all? I notice it. Check your error, dante.

EDIT: Seems there's no P3 for declaring it as player 3 which means (2, entity) from player property.
 
There, way better.
Everytime you saw "Invalid external declaration 'if' (in production 'external_decl')", it means there is a problem with with the "if" statement - either by a wrong "}" or a missing ";"

In your case, there is two problems:

1- wrong "}" at end

    void stageName;
    if (!stageName){
    setglobalvar("stageName","stage6-3"); // Put your stage name here. It's CASE SENSITIVE.
    }

    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P3 = getplayerproperty(1, "entity");
    setglobalvar("clearCount", 1);

    if(P1){
      changeopenborvariant("nojoin", 1);
      changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW50"));
    }
    if(P2){
      changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW50"));
    }
    if(P3){
      changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW50"));
    }
}
I suggest you to use Notepad ++ since it helps you to detect this kind of error

2 - you are declaring P2 two times, instead of P3.

    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P3 = getplayerproperty(2, "entity");
 
Finally works perfect my friend, thanks!

I just used it for the level of the bulldozer and now when you lose all the lives, you can continue from the stage before it is restarted.

I just need your help one more time, to know how I can add more stages to the anim spawn script and a specific anim follow that corresponds to it.
I did some tests, but I think I'm lost.
 
Good :)

add this:
if (stageName == "stage5-3"){
    *insert animation change here*
    }

change to the desired value.
(Sorry, I am typing on my phone at the bed).
 
After testing the script many more times, I discovered that it does not work correctly.
The idea is that only in the Stage6-3 change to the follow50 anim.
But he does it at all levels.

Code:
anim respawn
@script
     void stageName;
     if (!stageName){
     setglobalvar("stageName","stage6-3"); // Put your stage name here. It's CASE SENSITIVE.
     }

    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P3 = getplayerproperty(2, "entity");
    setglobalvar("clearCount", 1);

    if(P1){
      changeopenborvariant("nojoin", 1);
      changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW50"));
    }
    if(P2){
      changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW50"));
    }
    if(P3){
      changeentityproperty(P3, "animation", openborconstant("ANI_FOLLOW50"));
    }
@end_script
	loop	0
        delay	1
	offset	1 1
	frame	data/chars/caro/empty.png
        delay	9
	@cmd	spawnbind "pspawn" 0 0 1  0 0
	sound	data/sounds/respawn.wav
	frame	data/chars/caro/empty.png
	frame	data/chars/caro/empty.png
        delay	4
	offset	95 173
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
	frame	data/chars/caro/spawn1.png
	frame	data/chars/caro/spawn2.png
        delay	12
	frame	data/chars/caro/bfat00.png
	frame	data/chars/caro/select0.png
 
For sure it won't work - you are using it wrongly. You are setting the global variable inside the code...

As I said to you, try to READ the code, to think about it. Its very frustrating trying to help someone who doesn't listen :(
 
O Ilusionista said:
For sure it won't work - you are using it wrongly. You are setting the global variable inside the code...

As I said to you, try to READ the code, to think about it. Its very frustrating trying to help someone who doesn't listen :(

Sorry my friend, It's not that I do not listen to you, I honestly do not understand you.
I tried several different ways and I can not make it work.
And I assure you that it is more frustrating to try to do something you do not understand ...

In the tutorial you give the example of how to use the script in two ways:
1) Level script
2) Inside the spawn entity in level

But there is not an example of how to use the script within an animation as ANIM RESPAWN. You give me some tips to use it, but without an example to follow, it becomes extremely difficult to understand.
Also, you recommend me to see how you use it in your mod and there my confusion increases more, because I find things that are not in the tutorial.

Here an example of you level sky1:
Code:
spawn   empty
@script
void main()
{
     void stageName;
     void stageType;
     if (!stageName){
     setglobalvar("stageName","Sky Stage");
     }
     if (!stageType){
     setglobalvar("stageType","air");
     }

    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    setglobalvar("clearCount", 1);

    if(P1){
      changeopenborvariant("nojoin", 1);
      changeentityproperty(P1, "position", -200,150, 0);
      changeentityproperty(P1, "direction", 1); //Face right
      changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW60"));
    }
    if(P2){
      changeentityproperty(P2, "position", -200,170, 0);
      changeentityproperty(P2, "direction", 1); //Face right
      changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW60"));
    }
}
@end_script
coords   180 189
at   0

In this case you use the script Inside the spawn entity in level. but I see that there is another line in the script, which is not in the tutorial:
Code:
 void stageType;
This confuses me even more ...

I think the best thing is to open a new thread, since what I want to do, is not exactly what is explained in this tutorial.
 
O Ilusionista, why is my comment removed silently? I just mentioned something i had noticed. Now i see that you edited the first page, but was it really necessary to silently remove my comment like that?

By the way, the code is not just "modified". It is just the same Bloodbane posted back then. But props to you for the tutorial i guess.
 
This is my previous comment that I've moved, just to let you know

magggas  I have no intention in stealing other people credits, at all. The version I did is a tad different from the Bloobane version but yes, he should be credited - when I found this code, I forgot who made it (back when I was just copy and past codes on my notepad without knowing who did them - now I simply forward the topic to me).

I will be crediting Bloobane for sure, thanks for pointing me that error :)

Note: Its not the first time you have "something" with my tutorials - I remember you had a rage burst on the past thanks to that and I am trying to ignore.
But you are starting to get on my nerves...

edit: topic fixed
 
O Ilusionista said:
magggas because you pointed me an error, I've fixed it but you insist in derailing the topic. Again.

Maybe i'm "derailing" the topic now because you forcing me to, but why "again"?
My previous post had some valid points ant facts don't you think? Still you are not answering me on why it had to be deleted, so that we can move on, sice i don't get it. Wahat was the deal?
 
Back
Top Bottom