platforms in entity and respawns

ABK

Well-known member
Im making platform stage in my mod but i would like to use only platforms in entity but when i do that then when i respawn i fall into the hole, is there any way to recognize where platform is and respawn my character there ?
--
I see that there has to be real panel floor and engine recognizes it or does it recognize end of the hole and spawns character after it ?
 
I had the same problem like that. You may need script for the respawn (one for under the character txt file and one is a respawn.txt which will be the main command for helping a character to respawn in platforms). Let's say for example if you have a BG image that's like 2000x1000, the z panel will have to be 1000 for the hole (if you add hole into it). Also, in a level txt, you will need to have 3 parameters under coords for every entity if you are going to use a platformer style. coords {x} {z} {y}...

Respawn.txt:
name Respawn
type none
offscreenkill 3000
antigravity 100


anim idle
@script
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x");
    int a = getentityproperty(self,"a");

    setindexedvar(0, x);
    setindexedvar(1, a);
    killentity(self);
@end_script
loop 1
delay 5
offset 1 1
frame data/chars/misc/empty.gif

There is a respawn script under one character txt file for player here for anim respawn:
anim respawn
@script
    void self = getlocalvar("self");
    int x = getindexedvar(0); //Get respawn x coordinate
    int z = getentityproperty(self,"z"); //Get character's z coordinate
    int a = getindexedvar(1); //Get respawn a coordinate

    if(x==NULL()){
      x = getentityproperty(self, "x");
    }

    if(a!=NULL()){
      if(frame == 1){
        changeentityproperty(self, "position", x, z, a);
      }
    }
@end_script
delay 1
offset 23 66
frame data/chars/jj/stand1.png
frame data/chars/jj/stand1.png

Player 1 spawn. Here is 1spawn.txt:

name  1spawn
type  none
shadow  0

anim idle
@script
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x"); //Get character's x coordinate
    int z = getentityproperty(self,"z"); //Get character's z coordinate
    int a = getentityproperty(self,"a"); //Get character's a coordinate
    int P1 = getplayerproperty(0, "entity");

    changeentityproperty(P1, "position", x, z, a);
    killentity(self); //Suicide!
@end_script
  loop  1
  delay  5
  offset  1 1
  frame  data/chars/misc/empty.gif

Levels.txt for the ice stage.

z 920 920 920
file data/levels/ice2.txt

Under the level txt for creating a platformer, you need to set the coords and the scrollpos. Let me show you.

spawn  1spawn #Beginning using this spawn for player to start the game here plus look at the coords and scrollpos here too
coords  20 920 455 #How long an entity spawns in x plane and y plane while the z plane is the farthest down in the bg image
at      0 #0+20= 20

spawn Empty
coords 4500 920 200
at 0 #4500+0=4500

spawn  Ice_Floor
coords  0 920 440
at      0

spawn  Respawn
coords  220 920 460
at      0 #0+220= 220

spawn  Ice_Block
coords  424 920 440
at      0 #0+424= 424

spawn Star
health 30
coords 700 920 600
at 0

#spawn  Empty
#coords  0 280
#at      500

spawn  Ice_Floor2 #The width of the platform sprite is 301 because the resolution in the game is 480, so that means the x plane/coord is totalled 781. 480 + 301 = 781
coords  781 920 632 #Sum the number of the width of the scrollpos and the x coord, but the number of the scrollpos under entity have to be in order
at      17 #781+17= 798

spawn Star
health 30
coords 900 920 700
at 17


spawn  Respawn
coords  0 920 600
at      500

spawn  Ice_Panel
coords  528 920 714
at      682 # 528+682= 1210

#spawn  Ice_Panel
#coords 480 920 714
#at    730

spawn  Ice_Panel
coords  528 920 714
at      767 #528+767= 1295

#spawn  Ice_Panel
#coords  480 920 714
#at      815

What I did with the platform stage is that I followed the BG image and I used that for referece. I coded the same as the BG.

EDIT: I forgot to mention about LevelEnd entity. Bloodbane posted it in his thread. (You could check it out for Generic Portals, Branch, etc.)
 
I made some platform stages in my first battletoads mod but now i wanted to do mod with completely no floor just platforms but i figured that lowest platform could act as floor cause engine recognizes where hole ends and spawns character behind hole so i put platform every screen lenght and that kinda solved the problem.Now would be coold if duck animation could be used to look down and move screen a bit, any idea how to do it ?
Theres script function to control the screen movement?
IDeally it would be nice to use duck or UP(but new animation for this would be better) to look up and down in platform levels, UP isnt ideal cause its used for walking but theres no alternative and duck was made specifically for platformers/games with same z min/max, i guess jumping should be enough for looking up.
 
I already set holes which I forgot to mention. No floors but platforms, that's what I'm trying to help you on.

I set holes in an ice stage here I think.
hole            0 924 0 0 9184 9184 440
hole            6158 924 0 0 163 163 50
hole            6936 924 0 0 3874 3874 440

You can copy the scripts from what I posted. :) Also, yes, lowest platforms act like floors but you need to set a (very big) hole and increase the Y (3rd parameter of coords for spawning entity/platform) in code, not using/spawning a hole image (from data/sprites). Your platform is set as floor when you don't increase the spawn.

spawn  Ice_Panel
coords  528 920 714 #Do NOT worry about it but keep it set as "floor." Try to make it move upward by increasing the 3rd par from the "floor" (from 0, I think, and try changing it to see).
at      682 # 528+682= 1210

 
Yes, multiple respawns I have. You need to set your respawn for a platform if you like to start in that level. (Man, I want to know how I could darken the fonts under code 'cause the white font is too bright for my eyes.) Setting respawns is tricky, but worth trying it. Look at here.

Code:
spawn   Respawn
coords  0 920 600
at      500

spawn   Ice_Panel
coords  528 920 714
at      682 # 528+682= 1210

#spawn  Ice_Panel
#coords 480 920 714
#at     730

spawn   Ice_Panel
coords  528 920 714
at      767 #528+767= 1295

#spawn   Ice_Panel
#coords  480 920 714
#at      815

spawn   Respawn
coords  0 920 700
at      850

#spawn   Ice_Panel
#coords  480 920 714
#at      898

spawn    Ice_Panel
coords   528 920 714
at       850 #850+528= 1378

#spawn	Ice_Block2
#coords	1250 920 441
#at	901 #901 + 1250 = 2151 

#spawn   Ice_Panel
#coords  480 920 714
#at      983

spawn    Ice_Panel
coords   528 920 714
at       935 #528+935= 1463

#spawn   Ice_Panel
#coords  480 920 780
#at      1109

spawn    Ice_Panel
coords   528 920 780
at       1061 #528+1061= 1589

#spawn   Ice_Panel
#coords  485 920 780
#at      1193

spawn    Ice_Panel
coords   528 920 780
at       1150 #528+1150= 1678

spawn   Respawn
coords  0 920 800
at      1225

#spawn   Ice_Panel
#coords  480 920 780
#at      1285

spawn    Ice_Panel
coords   528 920 780
at       1237 #528+1237 = 1765

#spawn	Big_Block
#coords	707 920 441
#at	1252

#spawn   Ice_Panel
#coords  480 920 780
#at      1368

spawn    Ice_Panel
coords   528 920 780
at       1320 #528+1320 = 1848

spawn   Big_Block
coords  480 920 441
at      1479 #480+1479 = 1959

#spawn	Big_Block
#coords	707 920 441
#at	1252

spawn   Respawn
coords  0 920 850
at      1610

spawn   Ice_Block2
coords  480 920 441
at      1671 #1671 + 480 = 2151

#spawn	Ice_Block2
#coords	1250 920 441
#at	901

spawn	Star
health	30
coords	480 920 700
at	1672

spawn   Respawn
coords  0 920 700
at      2000

#spawn   Ice_Block
#coords  480 920 186
#at      2502

spawn   Ice_Block
coords  795 920 186
at      2187 #795+2187 = 2982

#spawn   Ice_Block
#coords  480 920 186
#at      2809

spawn   Ice_Block
coords  795 920 186
at      2495

spawn   Ice_Block
coords  795 920 186
at      2803

spawn	Star
health	30
coords	795 920 400
at	2804

spawn   Respawn
coords  0 920 400
at      3050

#spawn   Ice_Block
#coords  480 920 186
#at      3118

#spawn   Ice_Block
#coords  480 920 186
#at      3564

spawn   Ice_Block
coords  795 920 186
at      3249

#spawn   Ice_Block
#coords  480 920 186
#at      4049

spawn   Ice_Block
coords  795 920 186
at      3734
 
@bWWd: the only way to 'look up or down' is by modifying cameraoffset with script. However, no matter how far you set, you can't leave your character from screen (kinda like Prehistorik 2 look)
 
Hum, that is intersting. We can manipulate arrays like we do in PHP and Actionscript, like shift?

And isn't better to just check if te variable is true instead of check if has a value? Boolean triggers ate read quicker than integer ones, at least in the other languages i know

like this:

if(x){
      x = getentityproperty(self, "x");
    }

    else(){
      if(frame == 1){
        changeentityproperty(self, "position", x, z, a);
      }
    }

Also, what types (and much) user variables we have in BOR?
 
IT would be best for you to download sourcecode and look them up cause some are not documented and were announced in logs only.
http://www.chronocrash.com/forum/index.php?topic=11.0
 
that respawn script is too complicated,  you also didnt told that you increased maxindexedvar in script.txt file which is first step or else everything crashes and i spent like 4 hours figuruing out why it crashes.Id rather write something which recognizes where character last time used his idle anim or walk anim and respawn him in that place again so respawn would be automatic and you dont have to setup 2 entities for this simple task.
Cant this even be hardcoded so engine checks where character was using idle/pain or walk animation last time and respawn him there? That would avoid problems like this in platformer stages and would not break compatibility, if people are using respawn then theyre overriding default one which fails in platformer stages.
For now i guess i need script in idle/land animation to get entity's coords and use them in respawn anim.
----------
Ok this is my solution, requires just two scripts, one in idle and one in respawn animation.
Here is idle script:
Code:
	@script
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x");
    int a = getentityproperty(self,"a");
       if(frame == 0){
    setindexedvar(0, x);
    setindexedvar(1, a);
    }
	@end_script

Here is respawn script:
Code:
@script
    void self = getlocalvar("self");
    int x = getindexedvar(0); //Get respawn x coordinate
    int z = getentityproperty(self,"z"); //Get character's z coordinate
    int a = getindexedvar(1); //Get respawn a coordinate

    if(x==NULL()){
      x = getentityproperty(self, "x");

    }

    if(a!=NULL()){
      if(frame == 0){
        changeentityproperty(self, "position", x, z, a+100);
      }
    }
	@end_script

And it works great , respawn where you was last time before death.
Anyone has better ideas or examples how to do it even faster ?
im posting this for people in future who would have similar problem, IMO something like this should be hardcoded really.Dont forget about increasing indexedvars in script.txt
Making 2 entities to setup autorespawn is useful if you really want to plan respawns but i wanted automatic behaviour and this works well for me.
 
Id rather write something which recognizes where character last time used his idle anim or walk anim and respawn him in that place again

This method is very risky. Entities can play IDLE and WALK while falling to hole, so if engine records this mid air position, the respawn script would be useless since player would be respawned above hole again.

If you want to know, try walking to fall to hole then stop before you actually got 'killed' by hole. See where you'll be respawned.

The respawn system I shared to maxman is basicly simple, what makes it complicated is how often respawn point should be refreshed. It could be rare or often, you can even only have one or 2 respawn points if you'd like.

This system also gives challenge so players can't just fall down anywhere they please and hope to be respawned close to where they fall.
And challenges them to travel the area safely before next respawn point is reached (activated actually)
 
;D

I think that is one of the reason why some platformers spawn with a balloon that gives you time to move to a safe place.
 
i have walkoff animation so it doesnt play any other anim when walking off platform, the only risk would be receiving attack when falling but that also leads to pain animation not to idle.
It didnt fail so far even once.Always spawns in nice place (where i was in safe position on platform).
So do you have some other automatic suggestion? MAybe detecting if player was in idle and wasnt in the air ?
 
A rather fantasy but effective solution is to make players fly during respawn. They can move anywhere allowing them to pick safe place to land after fly time is over.
 
Back
Top Bottom