Random Profiles

dantedevil

Well-known member
It's possible make a profile for every player to show random with the intro,  like capcom games.
Like CAPTAIN COMMANDO, sometimes plays intro, and sometimes show a character profile.
 
You can use logo.txt for that and webm video file or animated gif.
I dont remember if it repeats itself tho if its game over and no one plays for a while.
 
Might not be the best solution, but I guess it's possible to do something like that using playgif.

Code:
	int profileShown = getlocalvar("profileShown");
	if(profileShown == NULL() && openborvariant("current_scene") == "data/scenes/intro.txt"){
		setlocalvar("profileShown", 1);
		playgif("data/scenes/profile1.gif", 0, 0, 0);
	}

Placed in updated.c.

Then using random functions and elapsed_time variable it should be possible to recreate what you're aiming at.
 
Thanks Piccolo!

I think your method can work for this.

Can you show me a example with more the one profile and the intro?

And in wich file i need to set this:
Then using random functions and elapsed_time variable it should be possible to recreate what you're aiming at.

Thanks.
 
In the same place, but you can create an external file for this functionnality so as to not fill the base updated.c with too much specific lines.

Here's a more elaborated version (still not optimized and all, just to give you ideas) :

Code:
int profileShown = getlocalvar("profileShown");
	if(profileShown == NULL() && openborvariant("current_scene") == "data/scenes/intro.txt"){
		int profileNumber = randRange(0, 5);
		if(profileNumber != 0){ // if profileNumber = 0, just let the standard intro
			playgif("data/scenes/profile" + profileNumber + ".gif", 0, 0, 0);
		}
		setlocalvar("profileShown", profileNumber);
		
	} else if(profileShown != NULL() && openborvariant("current_scene") == "data/scenes/intro.txt"){
		// Intro ended, reset profilShown variable
		setlocalvar("profileShown", NULL());
	}

When intro start, it plays either one of the five "profiles" gif or just lets the intro continue.

You'll need to include/import these functions as well to run the code :

int abs(int value){
if(value < 0) return value * -1;
else return value;
}

int randRange(int min, int max){
int r = rand()%((max - min) + 1);
r = abs(r) + min;

return r;
}
 
I've tried doing this myself by modifying Piccolo's script and I had to make some adjustments to prevent updated.c from replaying the animated gif

Anyways, the script works well and I can make it show profiles in certain order or in random order :)
However, there's just one small bug: sometimes player need to Press Start when it appears on main menu for it to work. I don't understand why

[couple days later]

Ah I forgot to show my scripts, here they are starting from:

updated.c
Code:
void main(){
    int Shown = getindexedvar(0);

    if(Shown == NULL() && openborvariant("current_scene") == "data/scenes/intro.txt"){
      int Play = getindexedvar(1);
      setindexedvar(0, 1);

      if(Play == 1){
        setindexedvar(1, Play+1);
	playgif("data/scenes/paladin4.gif", 0, 0, 0);
      } else if(Play == 2){
        setindexedvar(1, Play+1);
	playgif("data/scenes/elf4.gif", 0, 0, 0);
      } else if(Play == 3){
        setindexedvar(1, Play+1);
	playgif("data/scenes/mage4.gif", 0, 0, 0);
      } else if(Play == 4){
        setindexedvar(1, 0);
	playgif("data/scenes/cleric4.gif", 0, 0, 0);
      } else {
        setindexedvar(1, Play+1);
      }
    }
}

The animated gifs in this script are just examples and they can be changed
This script will play regular intro on first run, then after main menu is shown, it will play the next gif i.e paladin4.gif when intro is played again. Then after main menu, it plays next one and so on until it plays last gif where it will reset to play intro again

You need this script as well:

update.c
Code:
void main()
{
   if(openborvariant("in_menuscreen")==1){
      setindexedvar(0, NULL());
    }
}

void oncreate()
{
    setindexedvar(1, 0);
}
 
I have updated this map demo to show how that script works

http://www.mediafire.com/download/9pb6pfcdoaqxbbs/Map2.rar

Since I don't have many scenes for intro, I just used some scenes I could find from old KDEQ demo
Anyways, the intro scenes are shown in certain order. So at first, you only see map scene but if you wait until intro is played again (make sure main menu is displayed), it will display fighter's scene. If you wait again, paladin's scene will be displayed. After this, it will reset to map scene again

dantedevil, I know you might need some modification for your mod but at least this demo could show youhow it works :)
 
When Press Start appears, click to show main menu then wait

I just figured out an idea to solve this problem but for now make sure you see main menu before waiting for intro scene to be played
 
Bloodbane said:
When Press Start appears, click to show main menu then wait

I just figured out an idea to solve this problem but for now make sure you see main menu before waiting for intro scene to be played

Ah ok, I see it now!

Thanks!!!
 
I noticed once you press start and it shows the random intro, it will show one again on the press start screen.  But after that it will revert to intro.txt again.

I just wanted the random intro part for a mod, so I copied updated.c and made this from update.c 

update.c
Code:
void main()
{// Update script for random intro scenes

    if(openborvariant("in_menuscreen")==1){
      setindexedvar(0, NULL());
    }
}

void oncreate()
{
    setindexedvar(1, 0);
}

Is anything else needed?
 
Back to main topic, I've tried inserting timer in the code to prevent the need of 'pressing start' BUT what happened is this:

1. If I set timer shorter than 20 seconds, the next intro/profile will be played BEFORE main menu is entered
2. If I set timer longer than 20 seconds, the purpose of playing next intro/profile isn't achieved cause default intro would be played before timer ends

Hmm.....
 
Yeah I tried editing too so it would check in_titlescreen instead of in_menuscreen, or check both, but it kept playing gif's on press start screen..

Thou it could be a nice effect for some mods.;)
 
I really like the idea of a varied intro screen; helps bring that arcade authenticity.  Anyway, I'm trying to get this attract script running on version 4432 (to take advantage of the playwebm function).  I have both update.c and updated.c the way Bloodbane posted with only a bit of tweaking...

Code:
void main(){
    int Shown = getindexedvar(0);

    if(Shown == NULL() && openborvariant("current_scene") == "data/scenes/intro.txt"){
      int Play = getindexedvar(1);
      setindexedvar(0, 1);

      if(Play == 1){
        setindexedvar(1, Play+1);
	playwebm("data/scenes/demo1.webm", 0);
      } else if(Play == 2){
        setindexedvar(1, 0);
	playwebm("data/scenes/demo2.webm", 0);
      } else {
        setindexedvar(1, Play+1);
      }
    }
}

The problem is it doesn't seem to be working.  I've played through the intro screen multiple times by pressing start and leaving it be, but still no luck.  Is it something I messed up in the code, or maybe attributes (bitrate, etc..) of the webm files?
 
Have you set alwaysupdate 1 in script.txt?
If you don't have that file then you need to make one and put it inside data folder together with models.txt and levels.txt
 
Back
Top Bottom