Jump to content

Same script file triggered for two different cutscenes

Recommended Posts

Hi everyone!

I ran into a problem that causes me serious headaches. Maybe I have an idea that can solve this problem, but I'm not sure if it would work. I am attempting to improve an old story mod by recording voice lines to the characters. Originally the mod only had subtitles.
To understand the problem, I'll have to go into details here.

The player character meets with the main villain in the first cutscene. A bunch of bad guys surround the player character. Everyone is in both_stand5 animation. There's dialogue, then the main villain orders his men to attack. The first cutscene ends here.
Script-wise the scene was built like this: There was one script file that contained the camera angles and the sound files for the subtitle references (the sound files were 5 seconds of silence), there was a second script which had the both_stand5 animation for all the characters present (and other behavioral stuff), and there was a third script which made the bad guys ignite their lightsabers at the end of the scene.
Initially, when I replaced the silent sound files with the recorded voice lines, everyone in the scene said the lines which resulted in extremely loud and distorted sounds. I managed to assign the player's voice lines by using the AFFECT command in the second script. I couldn't do this with the villain in the first script, it didn't work. What worked was I assigned the villain's voice lines also in the second script. It was a tricky one, but then this scene was done.

After you kill all of the main villain's troops, a second cutscene starts. In the scene a third character arrives. The three of them talk to each other. That's basically it.
And again, three script files work at the same time: One had the camera angles and the silent sound files, the second one had the both_stand5 animation for the villain and the player, and the third script had the both_stand5 animation for the third character.
And finally we get to the problem itself: the second script file in this cutscene is the exact same file that was used in the first cutscene! So the player and the villain in the second cutscene still say the voice lines from the first cutscene. At this point I was ready to give up all hope and quit... but anyway, I made a backup to that script file, then moved on and managed to make the second scene work perfectly.
So at this stage, I have the same file twice, one contains the commands for the first cutscene, and the other contains the commands for the second cutscene. What I have to do when I play the mod is to put the first script to the mod's .pk3 archive, play through the first scene, then save the game, quit to windows, put the other script into the archive, launch the game again and continue playing.

I did all of this back in August and I had no idea what to do until now. I was examining another mod's scripts today and I found that one cutscene's starting trigger was made by using the IF command in script. In the game you have to activate four switches in random order and that triggers the cutscene. So this got me thinking: Would it be possible to use this IF command to solve my problem? What if I open up this shared script file that contains the first cutscene's commands, somehow I add the IF command which would "tell" the game to trigger the next cutscene when all the bad guys are dead/killed by me? (Luckily, all the bad guys have unique scriptnames) And after that, I could add the second cutscene's commands under the IF commands. With that, I could have both cutscene's commands in the same file but it would play one after the other. Although, I would still have to find a way to prevent the game from re-triggering the script file when the second cutscene would start.
Or am I overcomplicating this? Is there a way to simply "tell" the game that it should trigger another script file for the second cutscene... without messing up the .bsp file?

Any help would be greatly appreciated! And I hope that what I just wrote down is understandable and it's not some lengthy gibberish. ūüėĄ English is not my first language.

Link to comment

With conversations, it's important to have the correct NPC play the voice line, so that the audio comes from the right direction and the correct mouth moved. Since the level originally had no audio, it didn't have to worry about that, and apparently had all voice lines in a single script?

I don't fully understand the problem you've encountered, can you link to the map you're editing?

Link to comment

I'm not actually editing the map, I'm editing the .ibi files in BehavEd. As I understand if I try to edit the map, I would have to redo all lighting of the map from scratch. And I don't even know how to edit the map... So I self-educated myself about BehavEd and editing .ibi files, that seemed a lot easier. And basically this is how things look as of now:
(This is the Dark Alliance 2 mod, by the way)

                                   CUTSCENE #1                                                 CUTSCENE #2
NPC_targetnames:    Mara Jade:      m3                                           Mara Jade:      dm
                                   Lord Telroth:    tell1                                         Lord Telroth:    tell1 (same npc)

scripts used:             Mara_Stand.ibi:  affect (m3+tell1)                   Mara_Stand.ibi:  affect (m3+tell1) (same file)
                                   dkyle.ibi:            cam angles+removes m3     dk.ibi:                  affect (tell1)

Above is a summary so you can see things more clearly. I'll add some commentary to clarify all of it.
In CUTSCENE #1, the Mara_Stand.ibi contains some behavior commands for both Mara (m3) and Telroth (tell1) without using the 'affect' command on them. Then for the voice lines I had to put them under 'affect' commands, so this is how it looks:

set ( "SET_IGNOREENEMIES", "true" );
set ( "SET_IGNOREALERTS", "true" );
set ( "SET_IGNOREPAIN", "true" );
set ( "SET_ANIM_HOLDTIME_BOTH", -1.000 );
set ( "SET_SABERACTIVE", "false" );
wait ( 3000.000 );

affect ( "tell1", FLUSH )
    sound ( CHAN_VOICE_GLOBAL, "sound/text/T_126.mp3" );

wait ( 4200.000 );

affect ( "m3", FLUSH )
    sound ( CHAN_VOICE_GLOBAL, "sound/text/T_127.mp3" );

wait ( 3800.000 );

In the dkyle.ibi file, there are commands for all the camera angles, but at the bottom there is a command to remove Mara (m3) at the end of the scene. Telroth (tell1) remains, however.

In CUTSCENE #2, the same Mara_Stand.ibi file is used which still contains the commands for CUTSCENE #1. This results in Mara (dm) not saying anything because her voice lines are referenced for Mara (m3), and Telroth (tell1) interrupts himself because the Mara_Stand.ibi and dk.ibi files are running at the same time so the game plays his voice lines from both cutscenes simultaneously.

And this is the issue, that the same .ibi file is triggered for both cutscenes which messes up CUTSCENE #2. I've already made another .ibi file and with that CUTSCENE #2 would be perfect, but then CUTSCENE #1 would get all messed up. Simply put, my question is: is there a way to make both cutscenes work properly?

Link to comment

When I said "editing the map" I wasn't referring to just the .bsp, but also editing the scripts. But FYI you can actually edit the entities in a map without having to decompile it (and losing lighting etc.), it's a process called "entity modding" and there are multiple tutorials about it on this website.

So one solution would be to use entity modding to change cutscene 2 to run a different script than Mara_Stand.ibi. Another might be to put all the logic into dkyle.ibi and dk.ibi and leave Mara_Stand.ibi empty?

Link to comment

Easiest way I can think of is to let the script run twice, but use a script that is run before it to declare a variable or set a parm and then run a check so that it runs the first part during the first cutscene and the second part during the second, like this:

declare ( /*@DECLARE_TYPE*/ FLOAT, "script_stage" );
set ( "script_stage", "1" );

in the early script;


if ( $script_stage$, $=$, $2$ )
    rem ( "*Run second cutscene*" );

if ( $script_stage$, $=$, $1$ )
    rem ( "*Run first cutscene*" );
    set ( "script_stage", "2" );

in Mara_Stand.ibi. From what I experimented in the past it should be doable and work nicely in this case.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...