• 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 Restart Level on Death

Question that is answered or resolved.
Hmm... this one:

Code:
...
 if(getentityproperty(p1, "exists"))
{
 changeplayerproperty(0, "lives", p1lives -1);
 }
 if(getentityproperty(p2, "exists"))
{
 changeplayerproperty(1, "lives", p2lives -1);
 }
 if(getentityproperty(p3, "exists"))
{
 changeplayerproperty(2, "lives", p3lives -1);
 }
...

With these lines, if one player falls to hole, all players will lose one life instead of just the falling player. Is that what you want?

Also you're missing jumptobranch() function which works as the restarting script

About endlevel.c, it should be like this:

Code:
#include "data/scripts/story/story_clear.c"

void main()
{
   clearStory();
   setdrawmethod(NULL(),0,256,256,0,0,0,0,0,0,0,0,0,NULL());
   setindexedvar(1, NULL());
}

1) First set the ondeathscipt in all players.
2) Set this in the levels with the restart holes.

#1 and #2 are okay.
As for #3, you're right about using ondeatchscript to spawn the dialogue but that also means jumptobranch function should be moved to the dialogue entity to ensure dialogue is played fully before restarting
 
Hmm... this one:

Code: [Select]

...
if(getentityproperty(p1, "exists"))
{
changeplayerproperty(0, "lives", p1lives -1);
}
if(getentityproperty(p2, "exists"))
{
changeplayerproperty(1, "lives", p2lives -1);
}
if(getentityproperty(p3, "exists"))
{
changeplayerproperty(2, "lives", p3lives -1);
}
...


With these lines, if one player falls to hole, all players will lose one life instead of just the falling player. Is that what you want?

No, I want just the falling player lose one life.

Also you're missing jumptobranch() function which works as the restarting script
As for #3, you're right about using ondeatchscript to spawn the dialogue but that also means jumptobranch function should be moved to the dialogue entity to ensure dialogue is played fully before restarting

OK, but I don't know how spawn the diaogue in the ondeatchscript and how set  jumptobranch function to the dialogue entity.
This that you're telling me, is completely new to me.

Until now just use the jumptobranch with spawn an entity in enemy animation.
Then use onspawnscript to spawn the dialogue.

Code:
name	 GO6-3
type	none

onspawnscript data/bgs/branches/end6-3.c
animationscript data/scripts/obstacle.c 

anim idle
	delay	10
	offset	1 1
	frame	data/chars/misc/empty.png
        @cmd    anichange "ANI_FREESPECIAL1" 0
	frame	data/chars/misc/empty.png

anim freespecial1
	delay	2
	offset	1 1
        @cmd    restart
	frame	data/chars/misc/empty.png
	@script
    	void iStage = openborvariant("current_branch");
     	if(frame == 1){
    	jumptobranch(iStage, 1);
    	}
	@end_script
	frame	data/chars/misc/empty.png
	frame	data/chars/misc/empty.png
	frame	data/chars/misc/empty.png
 
No, I want just the falling player lose one life.

Ah, if that's the case, then don't set any of those :)

I don't know how spawn the diaogue in the ondeatchscript and how set  jumptobranch function to the dialogue entity.
This that you're telling me, is completely new to me.

Okay then, here's the ondeathscript :
Code:
void main()
{
    void self = getlocalvar("self");
    int Check = getindexedvar(1);
    int x = getentityproperty(self,"x");
    int z = getentityproperty(self,"z");
    int y = getentityproperty(self,"a");

    int H = checkhole(x,z,y);

    if(H == 1 && Check=="Chase"){
      spawn05("Dialog", 10, 10, 200);
    }
}

void spawn05(void vName, float fX, float fY, float fZ)
{
	//Spawns entity based on left screen edge and z axis
	//
	//vName: Model name of entity to be spawned in.
	//fX: X distance relative to left edge
	//fY: Y height from ground
      //fZ: Z coordinate

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int Direction = getentityproperty(self, "direction");
        int XPos = openborvariant("xpos"); //Get screen edge's position
        int Screen = openborvariant("hResolution"); // Get screen width

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

   if (Direction == 0){ //Is entity facing left?                  
      fX = Screen-fX; //Reverse X direction to match facing and screen length
   }

	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX + XPos, fZ, fY); //Set spawn location.
	return vSpawn; //Return spawn
}

This script will spawn Dialog entity 10 pixels from the left edge, 10 pixels above the ground and at z = 200 when player with this script falls to hole. You can adjust these yourself to suit your needs :)

The level restart script is moved to Dialog entity to allow dialogue to be played before restarting
name Dialog
type text
subtype noskip


anim idle
@script
  if(frame==1){ // at last frame
    void iStage = openborvariant("current_branch");

    jumptobranch(iStage, 1);
  }
@end_script
...

I've tested this and it works :D
 
Man, I HATE to be a pain!! I tried to use this for my Ranma ½ so that when the player dies the level will be restarted but, it didn't work. I set up the Branch and I assume levels "1" and "2" are just Dummy Levels. I added the script on the player's "death animation" and when the player "plays" its death animation OpenBOR just closes itself. I checked the Log and it says there was an exception while executing the player's script. I figured it might have something to do with "Stage Number" maybe but I'm not quite sure.
 
GaBoTiCo said:

GaBoTiCo, when you see the exception error, there's usually a more specific description of what happened further upstream in the log. Take a look or just post the whole log here and it might help.

DC
 
Thanks, DC  :) ! I will do that as soon as I get home.

UPDATE: So I got home and took screenshots of the .txt files. I hope this helps
 

Attachments

  • ScreenshotS.png
    ScreenshotS.png
    61 KB · Views: 11
That doesn't really give us a full view. Just copy the text files right into a post, and enclose them with code tags.

Code:
Example... text from y our files goes here...

Then we can diagnose your issue. :)

DC
 
Is there any way to end the level ( type 2 one without lifebars logic) ? I want quick level to reset variables but it still shows up for half a second showing lifebars and all.
How do you guys do that dummy level thats just for resetting variables and moving on?
--
Partially solved it by branching to empty branch with just credits but loading screen still blinks for a split second.

 
How do you guys do that dummy level thats just for resetting variables and moving on?

I usually use this quick level:
Code:
background	data/bgs/black.png
panel		data/chars/misc/0empty.gif none none
fglayer		data/bgs/black.png 100 0 0 0 0 0 0 -1 1 1
order		a
scrollspeed	0
settime		0 
notime		1
nofadeout	1
type		2 0 0


spawn	delay
@script
void main()
{
    jumptobranch("Lanjut",1);
}
@end_script
health	100
coords	480 500
at	0

It plays briefly without fadeout effect. Even if it shows for a split second, it only shows black image
 
I HATE to be a pain (yet again) but I tried this "ondeathscript" to spawn an entity like "Dialog" but with a different name that will restart current branch when the Player falls into a hole. It didn't work. I have no idea why. I "copied and pasted" the code and changed the name from "Dialog" to "Reinicio" and it just didn't work. Also, I do not understand the "spawn05" line.
 
It's been a while so I had to reread my posts to see what you're referring here.

I think I forgot to imply that before spawning anything, respective entity must be loaded first. So if you want to spawn Dialog entity, you either load it in entity's text or in models.txt. If it's going to be spawned by multiple entities' death, the latter is best solution. If you're going to spawn "Reinicio" on death, you should load that instead.

Also, I do not understand the "spawn05" line.

It's spawn function to spawn entity on specified z coord. I've shared the function together in ondeathscript so if you don't understand, just use it.
 
It's been a while so I had to reread my posts to see what you're referring here.

I think I forgot to imply that before spawning anything, respective entity must be loaded first. So if you want to spawn Dialog entity, you either load it in entity's text or in models.txt. If it's going to be spawned by multiple entities' death, the latter is best solution. If you're going to spawn "Reinicio" on death, you should load that instead.



It's spawn function to spawn entity on specified z coord. I've shared the function together in ondeathscript so if you don't understand, just use it.
Thanks a lot, Bloodbane!! I literally copied and pasted the "ondeathscript" script as it is. I even renamed my entity "Dialog" and it didn't work. Player's death animation also spawns "Dialog" and that worked, it restarts the branch but, it shows the "STAGE COMPLETE" screen. I believe I saw a script somewhere where you can prevent the stage number from increasing. I was thinking that perhaps you can force the player to play "anim death" when he/she falls into a hole.

UPDATE: I forgot to mention that most of my stages are pretty much a HUGE hole with a whole bunch of platforms. I was reading some other posts in the Forum and I believe at some point Bloodbane mentioned something about an "ondeathscript" or "checkhole" script that didn't work if the hole was clogged with platforms.
 
Last edited:
He may be using the "branch" command in some level entity's header. However, this branch command will not detect the current level, it needs to be entered manually.
This way you need to create a branch entity for every level, I think the scripted method is more practical.

Branch command (no script)

Scripted method, you can make it easily with a single line, plus detecting the current branch automatically. You can put this line in any animation that works during the character's death (pain, fall, death, etc).
 
He may be using the "branch" command in some level entity's header. However, this branch command will not detect the current level, it needs to be entered manually.
This way you need to create a branch entity for every level, I think the scripted method is more practical.
Unfortunately, this option doesn't suit me. I already have a many levels and 4 branches (8 planned in total). I'm afraid that the engine will not withstand such a load. Well, or I'm completely will confused in the code.

Please tell me something else. I would like to make a stealth level like in the example below. I use «ondeathscript.c» and «cranecounter.c» for player’s weapon so that the level would restart when the hero is detected (i.e. his death). But I get an error. The game crashes immediately after the death of the player. Do I have to add something to "spawn" or "death" for it to work correctly?

time 03:05
 
Back
Top Bottom