Starting a level in the middle

  • Thread starter Thread starter Gluestick
  • Start date Start date
G

Gluestick

Guest
I'm trying to make a non-linear game. One of the things I want to do is make it so a player can "enter" a both-direction level from multiple points (ex. the left side, right side, and points in between). So far I'm doing left and right by making two versions of the level, one for starting from each side. I'm having more difficulty starting a level in the middle of the level. I got the players appearing in the middle of the level like I want:

Code:
spawn   empty
@script
void main()
{
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    void self = getlocalvar("self"); //Get calling entity.

    changeentityproperty(self, "position", 837, 177, 0);
    if(P1){
      changeentityproperty(P1, "position", 837, 177, 0); 
      changeentityproperty(P1, "direction", 0); //Face left
    }
    if(P2){
      changeentityproperty(P2, "position", 837, 200, 0);
      changeentityproperty(P2, "direction", 0); //Face left
    }
}
@end_script
coords   430 200
at   0

But problems arise when a player hits a button in the couple of seconds it takes the camera to pan from the left side of the level to the middle of it. The player just pops up at whatever point the camera is at.

Are there any script commands to just jump the camera to a particular point? If not, is there a way to lock player inputs for those couple of seconds?
 
This is one reason I asked camera control scripts before.

Anyways, the crudest way to solve this is by setting high scrollspeed to the level so it scrolls so quick to middle of level before player has a chance to press a button.

If that doesn't satisfy you, you can try disabling player's control temporarily with this function:
     
  int Player = getplayerproperty(P, "entity");
  changeentityproperty(Player,"noaicontrol",Flag);

Set Flag 1 to disable player's control and set to 0 to reenable.

However, since you're doing this in a level, you either make special entity to disable player's control temporarily or with this technique: disable player control at start of level and spawn delay entity with group 1 1 to prevent other entities being spawned. After delay entity expires, reenable the control.
 
utunnels said:
Try changing xpos and ypos using changeopenborvariant.
This works perfectly. Thanks!

Code:
spawn   empty
@script
void main()
{
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    void self = getlocalvar("self"); //Get calling entity.

    changeentityproperty(self, "position", 837, 177, 0);
    if(P1){
      changeentityproperty(P1, "position", 837, 177, 0); 
      changeentityproperty(P1, "direction", 0); //Face left
    }
    if(P2){
      changeentityproperty(P2, "position", 837, 200, 0);
      changeentityproperty(P2, "direction", 0); //Face left
    }
    changeopenborvariant("xpos", 559);
}
@end_script
coords   430 200
at   0
 
I wonder how are your spawns set up?
Starting from middle means early part of the spawn list will still be actived if you proceed.
 
I have it set up like River City Ransom. No waits, and the player can run away from everyone if they really wanted to.

I was going to put a spawnscript on some enemies to change up what enemies come out depending on where you enter the level from or some other condition:
Code:
void main()
{
  void self = getlocalvar("self");
  void prevLevel = getglobalvar("prevLevel");
  if (prevLevel == "house")
	{
	  killentity(self);
	}
}

Edit: I was running into an issue regarding spawnscripts. I had two spawnscripts, the one above (entry.c), and one that alters an enemy's stats based on the remap its using (stats.c).

Code:
spawn	tshirt
map	9
spawnscript data/scripts/entry/entry.c
spawnscript data/scripts/enemy/stat.c
coords	360 160
at	0
For whatever reason, if I had it in this order, the enemy would still appear. Stat.c would still execute, entry.c would not. If I reverse the order (stat then entry) the enemy does not appear.
 
Multiple spawnscripts are no longer supported now, Gluestick. So the only solution is to copy the script from each spawnscript and paste it directly into level text.

spawn tshirt
map 9
@script
void main()
{
// Put your scripts here
}
@end_script
coords 360 160
at 0
 
Would #include work here? Like:
spawn tshirt
map 9
@script
#include data\scripts\spawn.c
void main()
{
spawn(1, 2.0, "Param");
}
@end_script
coords 360 160
at 0
 
utunnels said:
I wonder how are your spawns set up?
Starting from middle means early part of the spawn list will still be actived if you proceed.

Is there any good way around this?  Such as a way for an entity to get its intended spawn location, so it can kill itself in the spawnscript if it is somewhere else?
 
Back
Top Bottom