• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

Solved Spawn players over a platform , over a hole

Question that is answered or resolved.

oldyz

Well-known member
Greetings

i have been fixing some things, and there is a level or couple of levels where I would like players to begin standing on a platform that is going to fall -

if players are not careful and move out of the way, they fall along with the platform.

There is a problem tho
1 - i cant get players to spawn over a platform - it seems that unlike enemy entities, players can't spawn on the air
2 - even if i could spawn them over the platform, both the player & platform entity refuse to appear over a hole -

so far for the platform entity i have tested:
no_adjust_base 0 #no efect 0
subject_to_platform 0 # 0 no effect
subject_to_basemap 0 #no effect
and after it spawns it pops over the ground (and refuses to spawn floating over the hole)

so far the only thing i can think of is to spawn the players & use a jump or move within animation frames to force the players to move over the hole within a couple of centiseconds - and over the platform entity , which might have to have the same trick too...

but if this is not feasible - i wonder if a hole can be scripted to appear as the platform "falls" or goes away
 
Hi @oldyz,

players can't spawn on the air
both the player & platform entity refuse to appear over a hole

You can make players to spawn on the air and over a hole by using a script inside the following events:
- level file (or level.c)
- respawn#.c (where the # refers to the player number)
- join#.c (where the # refers to the player number)

level file
C:
@script
void main()
{
    void p1 = getplayerproperty(0, "ent");
    void p2 = getplayerproperty(1, "ent");
    void p3 = getplayerproperty(2, "ent");
    void p4 = getplayerproperty(3, "ent");
  
    if(p1){changeentityproperty(p1, "position", 300, NULL(), 300);}
    if(p2){changeentityproperty(p2, "position", 300, NULL(), 300);}
    if(p3){changeentityproperty(p3, "position", 300, NULL(), 300);}
    if(p4){changeentityproperty(p4, "position", 300, NULL(), 300);}
}
@end_script
at            0

respawn.c and join.c events
C:
void p1 = getplayerproperty(0, "ent");
void p2 = getplayerproperty(1, "ent");
void p3 = getplayerproperty(2, "ent");
void p4 = getplayerproperty(3, "ent");

if(p1){changeentityproperty(p1, "position", 300, NULL(), 300);}
if(p2){changeentityproperty(p2, "position", 300, NULL(), 300);}
if(p3){changeentityproperty(p3, "position", 300, NULL(), 300);}
if(p4){changeentityproperty(p4, "position", 300, NULL(), 300);}

The platform entity can be placed over a hole, you can follow the manhole example in SOR2X which is placed over a small hole. Here's the entity:
Code:
name            St1_Manhole
type            npc
hostile            player
subject_to_hole    0
health            1
nomove            1 1
noquake            1 0
bounce             1
shadow            0
stealth            2
setlayer        -2
animationscript    data/scripts/animation/default.c

anim idle
    loop    1
    delay    4
    offset    32 24
    platform 0 39 -10 -10 74 74 29 0.001
    frame    data/bgs/sor2/st1a/manhole00.png
    @cmd aniXpos 400 0 "ANI_FOLLOW1"
    frame    data/bgs/sor2/st1a/manhole00.png
  
anim follow1
    bouncefactor 3
    landframe 1
    loop    0
    delay    99
    offset    32 24
    @cmd sound "Metal.wav"
    @cmd leaper 1 4 0
    frame    data/bgs/sor2/st1a/manhole01.png
        delay    32
    @cmd sound "Metal.wav"
    frame    data/bgs/sor2/st1a/manhole00.png
    @cmd hurtSelf 1
    frame    data/bgs/sor2/st1a/manhole00.png
  
anim fall
    loop    0
    delay    12
    offset    32 24
    frame    data/bgs/sor2/st1a/manhole00.png

 
Last edited:
@Kratus

thank you very much , i will do the tests as soon as i can (i was thinking about a reply after testing, but have not had the chance to work on it)

Do you have any tips on how to make the Engine boot faster for testing?

there are some things like character animations that cannot be tested unless you completely close the engine and open it again, and its even worse if the module is big
I am wondering if there is a way for the engine to "reset" only the components used on the last level loaded...
 
I am wondering if there is a way for the engine to "reset" only the components used on the last level loaded...

You can use load Entity 1 in test level. Ex: load Garcia 1 in a level will load Garcia (enemy) when the level starts and unloads him when level ends. This is very useful way to test entities ;).
there is a level or couple of levels where I would like players to begin standing on a platform that is going to fall

There is a script to force players to start in certain coords when level starts. Here is example for player 1:
Code:
spawn    Empty
@script
void main()
{
    void P1 = getplayerproperty(0, "entity");

    if(P1){
      changeentityproperty(P1,"position", 300, 200, 50);
      changeentityproperty(P1,"direction", 0);
    }
}
@end_script
coords    320 460
at    0

This script places player 1 at x,z = 300,200 and 50 pixels above the ground when level starts. Technically, it is when this empty entity is spawned which is at scroll pos 0 and that's when level starts.
 
Thanks @Bloodbane,

i came back to save the thread for reference while i work on the thing

You can use load Entity 1 in test level. Ex: load Garcia 1 in a level will load Garcia (enemy) when the level starts and unloads him when level ends. This is very useful way to test entities .
Is there an equivalent of this feature for the main characters too? (not sure if they behave tho, so pardon the ignorance...)

about the script , it goes in the level.txt file , do i still have to declare these lines on them?

spawn1 150 60 0
spawn2 163 50 0
spawn3 228 35 0
spawn4 133 23 0
 
@oldyz

Do you have any tips on how to make the Engine boot faster for testing?
Is there an equivalent of this feature for the main characters too? (not sure if they behave tho, so pardon the ignorance...)
Usually the main heroes need to be loaded before the select screen appears, so they can't be loaded in the level file once the select screen comes before.
However, only for debug purpose you can use the updated.c event to run a script to load it before the select screen appears, like this:

Code:
void main()
{
    if(openborvariant("in_menuscreen"))
    {
        loadmodel("Axel", 3);
    }
}

By using the flag "3" both character/sprites will be unloaded as soon as the current level is finished. This way you don't need to close and reopen the game again.
PS: Don't forget to change "load" to "know" at the models.txt file in the defined character to make the script work properly.

about the script , it goes in the level.txt file , do i still have to declare these lines on them?

spawn1 150 60 0
spawn2 163 50 0
spawn3 228 35 0
spawn4 133 23 0
You don't need to use these lines because once the scripted method comes after it, all the player's positions will be changed anyway.


@Bloodbane
There is a script to force players to start in certain coords when level starts. Here is example for player 1:
Buddy, you can call the inline scripts directly inside the level file without spawning an entity (except if this entity is necessary in your game). You can see it working in the video I posted in my previous post.

I accidentally discovered it when I added a script in a level and forgot to put a spawn, however the "at" is still needed :)
 
Thanks @Kratus & @Bloodbane , the level is looking much more like the Arcade now, but i have ran into a new issue in when it comes to an aesthetic...
i will make anew thread about it
I accidentally discovered it when I added a script in a level and forgot to put a spawn, however the "at" is still needed :)
yes, sometimes when i cancel the first line of a spawn command
#spawn LiftPlank
coords 64 203 -50
at 0

the engine still loads a weird zombie entity that has no physical values
 
the engine still loads a weird zombie entity that has no physical values
At the first time I thought the same as you, but after looking at the source code I saw that the engine in fact supports "@script / @end_script" as native command for level files. This "zombie" spawn happens only if you put "coords" and "at" with no entity or script before it.
 
Buddy, you can call the inline scripts directly inside the level file without spawning an entity (except if this entity is necessary in your game).
Thanks for the tip, Kratus :D , I'll apply that when I have script which doesn't require entity.
That empty entity is my example is necessary but actually I moved the script there for efficiency.
 
@Bloodbane , i have run into an apparent issue with your script.

it seems that if the models have a custom spawn animation the script interrupts it, i have to test if Kratu's option does the same thing - if it does i might have to "merge" the custom model/animation script with the relocation scripts
 
Back
Top Bottom