News:

One Minute Game Review by The Happy Friar: https://ugetube.com/@OneMinteGameReviews
Also on Rumble: https://rumble.com/c/c-1115371

idTech 4 (aka Doom 3 tech) Discord Server! https://discord.gg/9wtCGHa

Main Menu

How to check if a cutscene is playing

Started by VGames, September 19, 2015, 02:18:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VGames

I need to remove a monster from the game when a cutscene is playing. How do u check if a cutscene is playing? I've looked in the events script and found nothing. I've tried adding the EnterCinematic and ExitCinematic voids to the monsters script but he doesn't respond to the code. I guess those only work for the player and weapons. Anybody know how to get this to work?
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

Phrozo

Maybe this might help. In cinematics you can call a function during a frame. Example from the map_hellhole.def:

model hellhole_cyberdeathrocks {
mesh models/md5/cinematics/hellhole/cyberdeath_rocks.md5mesh
anim open models/md5/cinematics/hellhole/cyberdeath_rocks.md5anim {
// the huge lava fire  549
frame 1 trigger soulcubefire
// rocksmoke ON
frame 27 trigger rocksmoke1
frame 52 trigger rocksmoke3
frame 63 trigger rocksmoke2
// rocksmoke OFF
frame 49 trigger rocksmoke1
frame 71 trigger rocksmoke3
frame 82 trigger rocksmoke2
// ROCKS HITTING THE GROUND
frame 39 trigger rock1explode
        frame 75 trigger rock2explode
// turn the huge lava fire off
frame 103 trigger soulcubefire
// fade  the lava out
frame 120 call "map_hellhole::fade_lava"
// turn off the room's particles
frame 90 trigger func_emitter_1
frame 90 trigger func_emitter_2
frame 90 trigger func_emitter_3
frame 90 trigger func_emitter_4
frame 90 trigger func_emitter_5

// added by phrozo
frame 90 call "map_hellhole::StopHellEmbers"
}
}


With the call keyword you can specify in string the function to call from namespace. So I'm not sure what map this is, but find the map script and add a function like this in the namespace:

void RemoveSomeMonster() {
    // directly reference it if you know it's name, but check if it exists first
    if ( $monster_demon_something ) {
        $monster_demon_something.hide();   // just want to hide it? do this
        $monster_demon_something.remove(); // or simply remove the monster all together
    }
}


Then during a cinematic, if you know the animation, call on a frame "map_script_object_name::RemoveSomeMonster"

And that should remove your monster.

VGames

Ok I'm gonna tell you exactly what I need. I need to remove a monster named pet_soulknight from the cpuboss map when the sabaoth death cinematic starts. I've tried doing what you said but was unable to get it to work. I started getting crashes with errors saying it couldn't find an animation called death for the sabaoth which makes no sense. Please help if u can.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

Phrozo

May I ask why you need to remove '$pet_soulknight' for this cinematic? What about other cinematics? I'll post the solution but this isn't ideal unless you only want specific instances of events like this.

Open up 'map_cpuboss.script'. Somewhere inside the curly braces of 'namespace map_cpuboss' insert this:
void RemovePetSoulKnight() {
if ( $pet_soulknight ) {
$pet_soulknight.remove();
sys.println( "map_cpuboss::RemoveSoulKnight: pet_soulknight has been removed" );
  }
}


Now open up 'map_cpuboss.def'. Modify 'model cpuboss_cin_sabaoth' to look like this:
model cpuboss_cin_sabaoth {
mesh models/md5/monsters/sabaoth/sabaoth.md5mesh

anim death models/md5/monsters/sabaoth/death.md5anim {
frame 200 skin skins/models/monsters/sabdeath.skin
frame 1               trigger sargeexplosion1
frame 1   call "map_cpuboss::RemovePetSoulKnight" // <- Add this line - Phrozo
frame 10   sound_voice sabaoth_death
frame 20              trigger sargeexplosion2
frame 35              trigger sargeexplosion3
frame 60              trigger sargeexplosion4
frame 85              trigger sargeexplosion5
}
}

VGames

Ok I see what I did wrong but I cannot try this out right now. Thanks for the help. The reason for this was because if a soul knight is present when the sabaoth is killed the game will crash once the cutscene ends. I'm hoping this will keep from that happening. A better solution would be to remove the soul knights anytime a cutscene is started but I can't find a way to check if a cutscene is occurring through the scripts. So this will have to work. I'll try this out ASAP. What u have here should work. I'll update when I can. If it's a success I'll do this for all cutscenes after the soul cube has been acquired since the soul cube is what u use to spawn a soul knight to help u.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

Phrozo

I know too well about cinematics crashing on me ;)

What script object is your soul knight using? There are a number of special functions that the game engine will automatically call on certain events. Two of them are 'EnterCinematics' and 'ExitCinematics'

void script_object::EnterCinematics() {
    self.hide(); // hide me as soon as cinematic begins
}

void script_object::ExitCinematics() {
    self.show(); // show me after done with cinematics
}


In fact, I don't even think you have to prototype these. The script parser will recognize them and re-define them with what it sees.

VGames

Hey I didn't know you had to have that self. part at the beginning of those commands. I was using remove(); in the entercinematic and exitcinematic functions that I added to the soulknights script file before trying to fix this crash. Of course there was no change. I'll try out everything you've told me ASAP. Thanks for the help. I'll update ASAP.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

Phrozo

You don't have to include the self keyword. It's implied but I explicitly write it most of the time. If you have any problems post the script interpreter errors and relevant script blocks.

VGames

Nothing seems to work. I've tried it like you said through the map scripts. I even called the void function to remove the soulknight through the player section of the cinematic instead of the sabaoth's part of the cinematic in the map's def file. I've tried adding the $pet_soulknight.remove(); command to the players exit and enter cinematic void functions. And I tried adding the enter and exit cinematics void functions to the soulknight's script aswell. I'm very much stumped. Maybe an addition to the pet mod code in the monster_base script would help. But I don't know how to check if the player is in a cut scene or not. The game always crashes just as the camera gets to the back of the head of the doomguy to go back into the player's view.

Adding just 1 "$pet_soulknight.remove();" command would get rid of all soulknights right? Or would that only get rid of one? Ive been testing with more then one. That's why I asked.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

Phrozo

Okay, so I'm not sure how to check if a cinematic is playing either but it is kind of irrelevant. Like I said, the EnterCinematics() function gets called on all script objects ( as far as I know ) when a cinematic starts and ExitCinematics() when a cinematic is done. If you want to do this from the player script, open up 'player_ai.script' and find the EnterCinematics() function. Add this inside the function:

if ( $pet_soulknight1 ) {
    $pet_soulknight1.remove();
}


By the way, make sure you know the name of whatever you are trying to manipulate with  the '$' symbol. The '$' symbol directly references a single entity with the name of the next immediate text. So no, '$pet_soulknight1' will not remove all pet soulknights, only one called "pet_soulknight1"

And if this fails, test without the pet_soulknight. I've made the sabaoths cinematic crash on me before so test to see if this is causing it.

VGames

Still doesn't work. I am so stuck. Really sucks. When the soul knight is spawned a random number is tacked on to it's name in the console. Like pet_soulknight_40 for example. That wouldn't have anything to do with this right? Also I forgot to mention that the soulknight is being spawned by the Soulcube's secondary attack projectile. Would that cause an issue with the cinematics?
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

Phrozo

Ah, you didn't tell me there were multiple entities of 'pet_soulknight' ...

Like I said, you have to know the exact name of an entity to use '$' or it will not work. This is why it's safe to use '$player1.hide();' for example because we know there is usually a "player1" ( you the player ) in the world, but there isn't always a "player2".

I've got one last solution that I'll post but there are a lot of details missing that you need to share.

- Where is it defined, and as what? File and exact entityDef name.
- Does it inherit from anything, like the monster_demon_hellknight?
- Do you know what script object it is using?  Look  for "script_object" in the entityDef.

All the things I have suggesting are proven solutions but they aren't being applied correctly. Finding the right script object will solve this, but I can't help any further without more details.

VGames

-The file name is pet_soulknight.def and the entityDef is "entityDef pet_soulknight".
-It does inherit from "monster_demon_hellknight".
-It uses a script object that I made for it using the Hellknight's script object as a base called "monster_demon_soulknight"

What do you have in mind?
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

Phrozo

I just did a test and it doesn't seem like the enter or exit cinematic functions get called on monsters ( for weapons and the player it does ), so we'll have to scrap that idea ( was part of my next solution sorry ).

So how many soulknights are there at any given time or what is the most that would ever exist in a map? If it is just one, you could just create a global entity variable called globalPetSoulKnight which would just be a reference and whenever the soulcube makes a soulknight, make globalPetSoulKnight equal it. But you're going to have to do what I originally suggested where in frame 1 of Sgt. Kellys death call the function 'map_cpuboss::RemovePetSoulKnight' but change the function to this:

void RemovePetSoulKnight() {
if ( globalPetSoulKnight ) {
    globalPetSoulKnight.remove();
}
}


I'm not sure how you make pet soulknights in script but assign a reference to globalPetSoulKnight as soon as make it.

There is one thing to consider. I used to have projectile script that ran a thread on death to run a function that needed more time than one frame would allow. It would crash the game after Sgt. Kelly death cinematic finished. I fixed it by terminating that thread on the frame I'm suggesting you use although I no longer have this problem because that was just me experimenting with script with some early alpha stuff which are no longer used.

VGames

How do I make a reference for global pet soul knight? Like what command do I use?
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500